Skip to content

Commit

Permalink
readme updated
Browse files Browse the repository at this point in the history
  • Loading branch information
EvilFreelancer committed Jul 7, 2018
1 parent 5c11689 commit 3fc6a4d
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ This library is ready for production usage, all source codes provided "as is".

About [migration to 1.8](https://github.com/DrTeamRocks/uon/wiki/Миграция-с-1.7-(и-ниже)-на-1.8-(и-выше)).

## Example of usage
## How to use

### Basic example
```php
<?php
require_once __DIR__ . "/../vendor/autoload.php";
Expand Down Expand Up @@ -54,7 +55,7 @@ All available methods of all classes with descriptions you can find [here](READM
* verify - Content verification
* cookies - Use cookies

Additional parameters for error 429
Additional parameters for "Error 429: Too many requests"

* tries - Count of tries if server answer 429 error code (default: 10)
* seconds - Time which need wait between tries (default: 1)
Expand All @@ -67,6 +68,45 @@ $config
->set('seconds', 2);
```

### About the page

Some GET methods have a `$page` parameter (with default state `1`),
and you can get only `100` items for one time it `$page` parameter is exist.

List of endpoints which have a `$page` parameter.

* /catalog-service/
* /cities/
* /hotels/
* /leads/$date_from/$date_to/
* /leads/$date_from/$date_to/$id_sources/
* /lead-by-client/$id_lead/
* /payment/list/
* /request-action/
* /requests/updated/
* /suppliers/
* /users/
* /user/updated/

These (I mean `$page`) parameter was added by API developers to reduce
the load on the server. So, do not worry if you see only 100 items in
result messages you just need write loop to get all items from API,
like this:

```
$i=1;
while (true) { // yeah, I know it's bad, better to use recursion
$response = $uon->requests->get($i);
$results[] = $response;
// Exit from loop if less than 100 items in answer from server
if (count($response->message) < 100) {
break;
}
$i++;
}
print_r($results);
```

## How to get API token

You need login into your account, then go to the
Expand Down

0 comments on commit 3fc6a4d

Please sign in to comment.