helpscout / helpscout-api-php

PHP Wrapper for the Help Scout API
MIT License
98 stars 62 forks source link

Conversation Pagination : stuck on first page #256

Closed jproy418 closed 3 years ago

jproy418 commented 3 years ago

Hi,

I'm not sure if I doing the right thing... I'm trying to to go through the results from $client->conversations()->list(). But I'm not able to go to the next page. It's always returning the results from the first page. I've tried with getNextPage() and getPage($i).

Also, when I combined the filter withQuery() and getPage($i), I'm getting the error :

Fatal error: Uncaught QL\UriTemplate\Exception: Invalid character at position 57: https://api.helpscout.net/v2/conversations?query=subject:"Avis d'octroi /"&status=all{&page} in /var/www/dev.sar.umontreal.ca/vendor/ql/uri-template/src/UriTemplate.php:44 Stack trace: #0

/////////// // Pagination /////////////

$filters = (new ConversationFilters()) ->withQuery('subject:"test"');

$conversations_list = $client->conversations()->list($filters); $nb_pages = $conversations_list->getTotalPageCount();

for($i = 1; $i<=$nb_pages;$i++){ $page_conversations = $conversations_list->getPage($i);

   /* Always returning 1 */
   echo $conversations_list->getPageNumber();

    foreach ($page_conversations as $conversation){
     /* */ 
}

}

Thanks!

jproy418 commented 3 years ago

Ok , I've found it.

I needed to use $page_conversations->getNextPage() in place of $conversations_list->getPageNumber;

Sorry!