API/lbcreposter.php

28 lines
809 B
PHP
Raw Normal View History

2016-08-21 22:54:00 +02:00
<?php
include 'vendor/autoload.php';
2016-08-24 22:30:13 +02:00
define('APP_DIR', dirname(__FILE__));
define('DEALS_DIR', sprintf('%s/deals', APP_DIR));
2017-09-30 15:42:09 +02:00
$script_params = parse_ini_file(sprintf('%s/lbcreposter.ini', DEALS_DIR), true);
$config = new \Shikiryu\LBCReposter\Config($script_params);
2017-09-30 15:42:09 +02:00
$account = new \Shikiryu\LBCReposter\Account($config);
$actions = new \Shikiryu\LBCReposter\Actions($account);
//$deal = \Shikiryu\LBCReposter\Deal::fromJSON(sprintf('%s/deals/tmp/data.json', APP_DIR));
2016-08-21 22:54:00 +02:00
2017-09-30 15:42:09 +02:00
if ($actions->connect()) {
2016-08-21 22:54:00 +02:00
// existing deals
2017-09-30 15:42:09 +02:00
$deals = $actions->retrieve();
2016-08-24 22:30:13 +02:00
/** @var \Shikiryu\LBCReposter\Deal $deal */
2017-09-30 15:42:09 +02:00
foreach ($deals as $i => $deal) {
2016-08-24 22:30:13 +02:00
$deal->save(DEALS_DIR);
}
2017-09-30 15:42:09 +02:00
// $account->addDeal($deal);
2016-08-21 22:54:00 +02:00
var_dump($deals);
2017-09-30 15:42:09 +02:00
} else {
echo 'not connected';
2017-09-29 16:01:01 +02:00
}