Skip to content

Commit 3610c4c

Browse files
committed
Release v1.3.0
1 parent 00d1216 commit 3610c4c

16 files changed

+632
-456
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/vendor
22
*.cache
33
/composer.lock
4+
/.idea

Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,10 @@ RUN mkdir /.config && chmod 777 /.config
1212
RUN mkdir /.composer && chmod 777 /.composer
1313
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
1414

15+
# Xdebug settings
16+
RUN echo "xdebug.mode=develop,debug,trace,profile" >> "$PHP_INI_DIR/conf.d/docker-php-ext-xdebug.ini"
17+
RUN echo "xdebug.start_with_request=trigger" >> "$PHP_INI_DIR/conf.d/docker-php-ext-xdebug.ini"
18+
RUN echo "xdebug.profiler_output_name=cachegrind.%t" >> "$PHP_INI_DIR/conf.d/docker-php-ext-xdebug.ini"
19+
RUN echo "xdebug.output_dir=/app/tests" >> "$PHP_INI_DIR/conf.d/docker-php-ext-xdebug.ini"
20+
1521
WORKDIR /app

README.md

Lines changed: 18 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ use Yahooauc\Browser as Browser;
2323
2424
$userName = "your_yahoo_user";
2525
$userPass = "your_yahoo_pass";
26-
$appId = "your_app_id";
2726
2827
/* Get saved cookie */
2928
$cookie = file_get_contents('cookie.cache');
3029
$cookieJar = $cookie !== false ? unserialize($cookie) : [];
3130
32-
$browser = new Browser($userName, $userPass, $appId, $cookieJar);
31+
$browser = new Browser($userName, $userPass, null, $cookieJar);
3332
```
3433
If you don't have cookies yet try to login into Yahoo.
3534
It throws `LoginException` or `CaptchaException` if something wrong.
@@ -79,86 +78,65 @@ Replace `test_user` with something else to throw `LoginException`. It means the
7978
```
8079
$userName = "not_test_user";
8180
$userPass = "secret_password";
82-
$appId = "app_id_random_hash";
8381
84-
$browser = new Browser($userName, $userPass, $appId, []);
82+
$browser = new Browser($userName, $userPass, null, []);
8583
$browser->debug($debug = true);
86-
```
87-
Replace `app_id_random_hash` with something else to throw `ApiException`.
88-
Pass something other than the following format `x000000000` to throw `ApiException`. It means the auction ID is invalid.
89-
Pass something in the following format `x000000000` like `x000000001` to throw `ApiException`. It means the auction not found.
84+
```
85+
Pass the following id `n000000000` to throw `PageNotfoundException`. It means the auction not found.
9086
```
9187
$userName = "test_user";
9288
$userPass = "secret_password";
93-
$appId = "not_app_id_random_hash";
9489
95-
$browser = new Browser($userName, $userPass, $appId, []);
90+
$browser = new Browser($userName, $userPass, null, []);
9691
$browser->debug($debug = true);
97-
$browser->getAuctionInfoAsXml("xxxxxxx01");
98-
$browser->getAuctionInfoAsXml("x000000001");
92+
$browser->getAuctionInfoAsXml("n000000000");
9993
```
10094
Get an array of fake data from the first bidding page.
10195
```
10296
$userName = "test_user";
10397
$userPass = "secret_password";
104-
$appId = "app_id_random_hash";
10598
106-
$browser = new Browser($userName, $userPass, $appId, []);
99+
$browser = new Browser($userName, $userPass, null, []);
107100
$browser->debug($debug = true);
108101
$browser->getBiddingLots(1);
109102
```
110103
Get an array of fake IDs from the first won page.
111104
```
112105
$userName = "test_user";
113106
$userPass = "secret_password";
114-
$appId = "app_id_random_hash";
115107
116-
$browser = new Browser($userName, $userPass, $appId, []);
108+
$browser = new Browser($userName, $userPass, null, []);
117109
$browser->debug($debug = true);
118110
$browser->getWonIds(1);
119111
```
120-
Bid on the following lot `e000000000` to throw `BrowserException`. This auction has already ended.
112+
Bid on the following lot `e000000000` to throw `AuctionEndedException`. This auction has already ended.
121113
Bid on the following lot `x000000000` with price under `220` to throw `BrowserException`. It means your price is lower than the current price.
122114
Bid on the following lot `x000000000` with price between `220` and `999` to throw `RebidException`. It means the price of the lot has rose, and the bid failed.
123115
Bid on the following lot `x000000000` with price more than `999` for a successful bid.
124116
```
125117
$userName = "test_user";
126118
$userPass = "secret_password";
127-
$appId = "app_id_random_hash";
128119
129-
$browser = new Browser($userName, $userPass, $appId, []);
120+
$browser = new Browser($userName, $userPass, null, []);
130121
$browser->debug($debug = true);
131122
$browser->bid("e000000000", 1000); // Has already ended
132123
$browser->bid("x000000000", 100); // Not enough
133124
$browser->bid("x000000000", 500); // Rebid page, bid failed
134125
$browser->bid("x000000000", 1000); // Success
135126
```
136127

137-
## About v1.2.x
128+
## About v1.3.x
138129

139130
### Features
140-
- Detect a page with a captcha. If you send a lot of requests to login.
141-
- Detect a page with ban. If you send too many requests to login.
142-
- Added method to check login. `checkLogin()`
143-
- The `getBiddingLots()` method and `getWonIds()` now throw `LoggedOffException`
144-
- The `login()` method throws `LoginException` and `CaptchaException`
145-
- The `bid($auc_id, $price)` method now throws `ApiException`, `BrowserException`, `RebidException`, `AuctionEndedException`
146-
- You can emulate very many attempts to login in debugging mode.
147-
- You can emulate too many attempts to login and get ban in debugging mode.
148-
149-
### Bugfixes
150-
- Fixed Yahoo login.
151-
- Fixed checking login.
131+
- Added xdebug to docker container.
152132

153133
### Updates
154-
- Login to Yahoo has moved to a separated method from the constructor of the class.
155-
- The `ParserException` won't throw anymore, instead `BrowserException` will be thrown
156-
- Updated the composer.json file
157-
- Other refactoring of a code.
134+
- Yahoo auction API was removed because Yahoo fully closed their API.
135+
- If the page or lot not found it will throw `PageNotfoundException`.
158136

159137
### Notes
160-
- Replaced `rmccue/requests` with `guzzlehttp/guzzle`
138+
- Field `$appId` don't need anymore, pass null instead to the `Browser` constructor.
139+
- Method `$browser->getAuctionInfoAsXml("...")` returns shorted version of API result. Currently, available fields: `Title`, `Seller->Id`, `Img`, `Price`, `TaxinPrice`, `StartTime`, `EndTime`, `Status`.
161140

162-
### Migration from v1.1.x
163-
- You need call `$browser->login()` manually after creating the `Browser` class
164-
- Also, try to learn from code.
141+
### Migration from v1.2.x
142+
- Check available fields for `$browser->getAuctionInfoAsXml("...")` in Notes.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"homepage": "https://github.com/notfoundsam"
1111
}
1212
],
13-
"version": "1.2.3",
13+
"version": "1.3.0",
1414
"license": "MIT",
1515
"require": {
1616
"ext-simplexml": "*",

examples/main.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
use Yahooauc\Browser as Browser;
66
use Yahooauc\Exceptions\AuctionEndedException;
7+
use Yahooauc\Exceptions\BrowserException;
78
use Yahooauc\Exceptions\CaptchaException;
89
use Yahooauc\Exceptions\LoggedOffException;
910
use Yahooauc\Exceptions\LoginException;
1011

1112
$userName = "test_user";
1213
$userPass = "secret_password";
13-
$appId = "app_id_random_hash";
14+
$appId = null;
1415

1516
$captchaId = "AgAAAIkBAAABAAAAAAAAAAABA";
1617
$captchaAnswer = "くやひよかとむちひな";
@@ -25,10 +26,10 @@
2526
$browser->debug(true);
2627

2728
/* Emulate very many attempts to login */
28-
$browser->debugShowCaptcha(true);
29+
// $browser->debugShowCaptcha(true);
2930

3031
/* Emulate too many attempts to login and get ban */
31-
$browser->debugYahooBlocked(true);
32+
// $browser->debugYahooBlocked(true);
3233

3334
/* Check is logged in */
3435
var_dump($browser->checkLogin());
@@ -41,7 +42,7 @@
4142
// var_dump($browser->loginWithCaptcha($captchaId, $captchaAnswer));
4243

4344
/* Get information about lot */
44-
var_dump($browser->getAuctionInfoAsXml("lotId"));
45+
var_dump($browser->getAuctionInfoAsXml("e000000000"));
4546

4647
/* Get list of lots from first bidding page */
4748
var_dump($browser->getBiddingLots(1));
@@ -50,7 +51,7 @@
5051
var_dump($browser->getWonIds(1));
5152

5253
/* Bid on lot */
53-
var_dump($browser->bid("lotId", 100));
54+
var_dump($browser->bid("x000000000", 100));
5455

5556
/* Save latest cookie */
5657
$cookieJar = $browser->getCookie();
@@ -62,6 +63,8 @@
6263
echo trim($e->getMessage())."\n";
6364
} catch (AuctionEndedException $e) {
6465
echo trim($e->getMessage())."\n";
66+
} catch (BrowserException $e) {
67+
echo trim($e->getMessage())."\n";
6568
} catch (CaptchaException $e) {
6669
echo $e->getMessage()."\n";
6770
echo $browser->getCaptchaId()."\n";
@@ -74,4 +77,3 @@
7477
} catch (Exception $e) {
7578
echo trim($e->getMessage())."\n";
7679
}
77-

src/AuctionXml.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
namespace Yahooauc;
4+
5+
use SimpleXMLElement;
6+
7+
class AuctionXml
8+
{
9+
private $html;
10+
private $xml;
11+
12+
public function __construct($body)
13+
{
14+
$this->html = Parser::getHtmlDom($body);
15+
$this->xml = new SimpleXMLElement('<ResultSet><Result></Result></ResultSet>');
16+
17+
$this->addTitle();
18+
$this->addSellerId();
19+
$this->addImagesUrl();
20+
$this->addPrice();
21+
$this->addDetail();
22+
$this->addStatus();
23+
}
24+
25+
public function setAuctionId($auctionId)
26+
{
27+
$this->xml->Result->AuctionID = $auctionId;
28+
}
29+
30+
public function setAuctionUrl($url)
31+
{
32+
$this->xml->Result->AuctionItemUrl = $url;
33+
}
34+
35+
public function getXml()
36+
{
37+
return $this->xml;
38+
}
39+
40+
private function addTitle()
41+
{
42+
$this->xml->Result->Title = Parser::getAuctionTitle($this->html);
43+
}
44+
45+
private function addSellerId()
46+
{
47+
$this->xml->Result->Seller->Id = Parser::getAuctionSellerId($this->html);
48+
}
49+
50+
public function addImagesUrl()
51+
{
52+
$this->xml->Result->addChild('Img');
53+
54+
foreach (Parser::getAuctionImagesUrl($this->html) as $key => $url) {
55+
$childName = 'Image'.++$key;
56+
$this->xml->Result->Img->$childName = $url;
57+
}
58+
}
59+
60+
public function addPrice()
61+
{
62+
$data = Parser::getAuctionPrice($this->html);
63+
64+
$this->xml->Result->Price = $data['price'];
65+
$this->xml->Result->TaxinPrice = ($data['taxPrice'] > 0) ? $data['taxPrice'] : $data['price'];
66+
}
67+
68+
public function addDetail()
69+
{
70+
$data = Parser::getAuctionDetail($this->html);
71+
72+
$this->xml->Result->StartTime = $data['start'];
73+
$this->xml->Result->EndTime = $data['end'];
74+
}
75+
76+
private function addStatus()
77+
{
78+
$this->xml->Result->Status = Parser::getAuctionStatus($this->html);
79+
}
80+
}

0 commit comments

Comments
 (0)