Jump to content
Sign in to follow this  

Indeed API

Recommended Posts



I'm trying to detect whether <totalresults> = 0 from the Indeed API.


Here is the code I'm using:


$search ='oihhb';           

$xml = simplexml_load_file('http://api.indeed.com/ads/apisearch?publisher=xxxxxx&q='.$search.'&l=&sort=&radius=&st=&jt=&start='.$start.'&limit=1&fromage=&filter=&latlong=1&co=fr&chnl=&userip=');

foreach($xml->results->result as $result)
       if ($xml->totalresults == 0) {
         echo 'empty';   } else   { 
     echo $xml->totalresults;

As you can see from the code above, I'm searching for $search ='oihhb'; which purposely doesn't return any results - see <query> below:

<response version="2">

So I want to do, it's to echo 'empty' if <totalresults> = 0 but I can't get it work i.e. I can't print 'empty'. However I have to say that I can print the total number of results: echo $xml->totalresults;


So must be something wrong with if ($xml->totalresults == 0).


If someone could point me to the right direction.


Many Thanks,

Edited by seb_london

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...