How do I paginate a CareerJet API results in PHP?

I’m using CareerJet API to build my jobsearch website, currently I’m almost done with everything except for one, paginating the gathered data I get from them, I could’ve solve it if its in the documention but apparently there is none and only says

# Basic paging code

if( $page > 1 ){
echo “Use $page - 1 to link to previous page\n”;
}
echo “You are on page $page\n” ;
if ( $page < $result->pages ){
echo “Use $page + 1 to link to next page\n” ;
}

now I don’t know what to put in there to make it work, I’ve tried following the instructions but It only redirect to the first page, this is my first project handling some API and PHP for my project in school and I would like to know how to do it. Please help me cause I really want to know.

https://www.careerjet.com/partners/api/php/

You’ll need to make another API request to get the next page of results.

$result = $api->search(array(
  'keywords' => 'php developer',
  'location' => 'London',
  'page' => $page ,
  'affid' => '678bdee048',
));

// snipped...
  echo "Found ".$result->hits." jobs" ;
  echo " on ".$result->pages." pages\n" ;
  $jobs = $result->jobs ;

Your $result object has a pages property which tells you how many pages are in the result. You can load a specific page by supplying a different 'page' value in the call to $api->search().

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service