How to deal with pagination in Canvas using PHP

Jump to solution
Community Explorer

I was trying to use pagination in my requests, I just try to show the Header that contains the "Link" values.

I use Guzzle with PHP

$res_aluno_pag = $client->request('GET', 'courses/'.$course_id.'/enrollments?type[]=StudentEnrollment&state[]=active&per_page=1000', ['headers' => $headers
var_export( $res_aluno_pag->getHeader("Link") );

This is the what appear in my screen

array ( 0 => '; rel="current",; rel="next",; rel="first",; rel="last"', )

But if I use postman, I can see the following result inside the "Headers" tab

<>; rel="current",
<>; rel="prev",
<>; rel="first",
<>; rel="last"

How can I use PHP and Guzzle to see the complete text/string that is inside the "Link" Header?

Labels (1)
1 Solution
Community Champion


I have not used Guzzle, but community developers have created a very nice resource for in various languages. If you figure out how to handle the pagination with Guzzle we'd love to see an example.

View solution in original post