2016-08-21 22:54:00 +02:00
|
|
|
<?php
|
|
|
|
include 'vendor/autoload.php';
|
|
|
|
include 'library/Account.php';
|
|
|
|
|
|
|
|
$client = new \Goutte\Client();
|
|
|
|
$client->setClient(
|
|
|
|
new \GuzzleHttp\Client([
|
2017-09-06 06:29:28 +02:00
|
|
|
'timeout' => 90,
|
|
|
|
'verify' => false,
|
|
|
|
'curl' => [
|
|
|
|
CURLOPT_TIMEOUT => 60,
|
|
|
|
CURLOPT_TIMEOUT_MS => 60,
|
|
|
|
CURLOPT_CONNECTTIMEOUT => 60,
|
|
|
|
],
|
|
|
|
'headers' => [
|
|
|
|
'User-Agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:39.0) Gecko/20100101 Firefox/39.0',
|
|
|
|
],
|
2016-08-21 22:54:00 +02:00
|
|
|
])
|
|
|
|
);
|
2017-09-06 06:29:28 +02:00
|
|
|
$client->setMaxRedirects(10);
|
2016-08-21 22:54:00 +02:00
|
|
|
|
2016-08-24 22:30:13 +02:00
|
|
|
define('APP_DIR', dirname(__FILE__));
|
|
|
|
define('DEALS_DIR', sprintf('%s/deals', APP_DIR));
|
|
|
|
|
|
|
|
$script_params = parse_ini_file(sprintf('%s/lbcreposter.ini.dev', DEALS_DIR), true);
|
2017-09-06 06:29:28 +02:00
|
|
|
$config = new \Shikiryu\LBCReposter\Config($script_params);
|
|
|
|
|
|
|
|
$account = new \Shikiryu\LBCReposter\Account($client, $config);
|
|
|
|
$deal = \Shikiryu\LBCReposter\Deal::fromJSON(sprintf('%s/deals/tmp/data.json', APP_DIR));
|
2016-08-21 22:54:00 +02:00
|
|
|
|
|
|
|
if ($account->connect()) {
|
|
|
|
// existing deals
|
|
|
|
$deals = $account->getDeals();
|
2016-08-24 22:30:13 +02:00
|
|
|
/** @var \Shikiryu\LBCReposter\Deal $deal */
|
|
|
|
foreach ($deals as $deal) {
|
|
|
|
$deal->save(DEALS_DIR);
|
|
|
|
}
|
2017-09-06 06:29:28 +02:00
|
|
|
|
|
|
|
$account->addDeal($deal);
|
|
|
|
|
2016-08-21 22:54:00 +02:00
|
|
|
var_dump($deals);
|
|
|
|
}
|