API/lbcreposter.php

30 lines
824 B
PHP

<?php
include 'vendor/autoload.php';
include 'library/Account.php';
$client = new \Goutte\Client();
$client->setClient(
new \GuzzleHttp\Client([
'timeout' => 90,
'verify' => false,
])
);
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);
$credentials = $script_params['CREDENTIALS'];
$login = $credentials['login'];
$password = $credentials['password'];
$account = new \Shikiryu\LBCReposter\Account($client, $login, $password);
if ($account->connect()) {
// existing deals
$deals = $account->getDeals();
/** @var \Shikiryu\LBCReposter\Deal $deal */
foreach ($deals as $deal) {
$deal->save(DEALS_DIR);
}
var_dump($deals);
}