Hello world

This commit is contained in:
Shikiryu 2016-08-19 23:02:07 +02:00
commit 581488037a
5 changed files with 95 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
/composer.phar
/index.php
/composer.lock
/vendor/
/.idea/

14
composer.json Normal file
View File

@ -0,0 +1,14 @@
{
"name": "shikiryu/lbcreposter",
"description": "Repost deal in LBC",
"type": "project",
"require": {
"fabpot/goutte": "^3.1"
},
"authors": [
{
"name": "Shikiryu",
"email": "clement@desmidt.fr"
}
]
}

60
library/Account.php Normal file
View File

@ -0,0 +1,60 @@
<?php
namespace Shikiryu\LBCReposter;
use Goutte\Client;
class Account
{
const HOME_URL = 'https://www.leboncoin.fr/';
const LOGIN_URL = 'https://www.leboncoin.fr/beta/ajax/popins/connexion.html';
const ACCOUNT_URL = 'https://compteperso.leboncoin.fr/account/index.html';
/** @var Client */
protected $client;
/** @var string */
protected $login;
/** @var string */
protected $password;
/** @var bool */
protected $is_connected = false;
/**
* Account constructor.
* @param Client $client
* @param string $login
* @param string $password
*/
public function __construct(Client $client, $login, $password)
{
$this->client = $client;
$this->login = $login;
$this->password = $password;
}
public function isConnected()
{
if (!$this->is_connected) {
$crawler = $this->client->request('GET', self::HOME_URL);
$this->is_connected = $crawler->filter('.loggedOut')->count() == 0;
}
return $this->is_connected;
}
public function connect()
{
if (!$this->isConnected()) {
$crawler = $this->client->request('GET', self::LOGIN_URL);
$form = $crawler->selectButton('Se connecter')->form();
$crawler = $this->client->submit($form, ['st_username' => $this->login, 'st_passwd' => $this->password]);
$this->is_connected = $crawler->filter('.account_userinfo')->count() > 0;
}
return $this->is_connected;
}
public function getDeals()
{
$crawler = $this->client->request('GET', self::ACCOUNT_URL);
// $deals = $crawler->filter('#dashboard .list .element')->each()
}
}

8
library/Deal.php Normal file
View File

@ -0,0 +1,8 @@
<?php
namespace Shikiryu\LBCReposter;
class Deal
{
}

8
library/Deals.php Normal file
View File

@ -0,0 +1,8 @@
<?php
namespace Shikiryu\LBCReposter;
class Deals
{
}