0

I am using http://issuu.com site in laravel for uploading documents and retrieving listing of it. I have a problem in fetching list from site. I want to get all records from http://issuu.com. I have used code

   $issuu = new Issuu('--my API key--', '--my API secret--');
   $documents = new Documents($issuu);
   $documentsList = $documents->list();

using above code i only get 0 to 9 records from all document list. I want to retrieve all records from that site.How can i get all documents list those are uploaded on that site?? can anyone please help me!

Mark Ormesher
  • 2,289
  • 3
  • 27
  • 35
  • I doubt you will be able to retrieve all the documents that are not related to you / your application. Simply because it is an API. You will get access only to your documents. I am not sure yet, haven't checked it properly. So, I can't comment more on it. And if I am wrong, then their API will have the documentation, you need to go through it thoroughly. – Saiyan Prince Jan 03 '19 at 08:05
  • @Mayuri Darji I submitted an edit to remove the credentials from the post, but if they weren't dummy values you should still generate new credentials ASAP and disable the ones that were posted here. – Mark Ormesher Jan 03 '19 at 08:12

1 Answers1

1

As documented here, the Documents->list() method takes parameters for the start index and page size, which default to 0 and 10 respectively (i.e. you get the first 10 results, starting from result #0). The maximum page size is 30, so if you have more document than that you'll need to make multiple requests to get all of them.

There's a good blog post here explaining API pagination, including how to get all results from a paged API. The crux of it is as follows (pseudocode, so you'll need to translate it to PHP and your API):

allResults = empty list
nextStart = 0
pageSize = 30
do {
    newResults = request $pageSize more results, starting at $nextStart
    add $newResults to $allResults
    nextStart = highest index in $newResults + 1
} while ($newResults indicates that there are more results)

The condition of the do...while loop will depend on your API. Some will include something like hasMore: true/false in their response, some will require you to keep going until you get zero results, etc.

Mark Ormesher
  • 2,289
  • 3
  • 27
  • 35