Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

Latest commit

 

History

History
64 lines (49 loc) · 1.46 KB

pagination.md

File metadata and controls

64 lines (49 loc) · 1.46 KB

Pagination

Description

Most of methods use Pinterest pagination. For example, when you run $bot->pins->search('query'), Pinterest returns only 20 results for request, you cannot get all the pins at once with only one request. So these methods return Pagination object. You can iterate over it to get results:

$pagination = $bot->pins->search('query');

foreach ($pagination as $pin) {
    // ...
}

As array

Or you can grab all results at once as an array, but it will require some time, to loop through all Pinterest pages to get these results:

$pagination = $bot->pins->search('query');

$results = $pagination->toArray();
// Or
$results = $bot->pins->search('query')->toArray();

Limit

By default methods return the first 50 results. For example, $bot->pins->search('query') will return only first 50 pins. But you can specify another limit num as a second argument. Or pass 0 for no limit. For example,

foreach ($bot->pins->search('query', 20) as $pin) {
    // ...
}

Will return only 20 pins of the search results.

Offset

Limit and offset in results:

// Skip first 50 results
$results = $bot->pins
    ->search('query')
    ->skip(50)
    ->get();

// Skip first 50 results, and then take 20
$results = $bot->pins
    ->search('query')
    ->take(20)
    ->skip(50)
    ->get();

To get all results pass 0 in take() method.