dirkgroenen / pinterest-api-php

A PHP wrapper for the official Pinterest API. :pushpin:
https://developers.pinterest.com/docs/getting-started/introduction/
Apache License 2.0
173 stars 76 forks source link

How to use fromBoard method? #90

Closed VadimSS closed 5 years ago

VadimSS commented 5 years ago

I am used this method this way:

$resp = $pinterest->pins->fromBoard('giftsbrains/gifts-for-women', $data = []);

But I got just first 25 pins from this board. How I can fetch all the pins from this board? I have no idea how ho use array $data parameter of this function, and what fields this array must include.

dirkgroenen commented 5 years ago

Responses with multiple instances are returned as a Collection. This class has the option to check a next page using hasNextPage().

If a next page is available you can retrieve the cursor from the Collection's pagination property and pass it along as $data = ['cursor' => $cursor] to your method.

$response = $pinterest->pins->fromBoard('giftsbrains/gifts-for-women');

if($response->hasNextPage()) {
  $cursor = $response->pagination['cursor'];
  $pinterest->pins->fromBoard('giftsbrains/gifts-for-women', [
    'cursor' => $cursor
  ]);
}
dirkgroenen commented 5 years ago

This will be in release 0.2.12