Jump to content

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
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...