0

I'm using the sample API from Indeed (Note, removed publisher ID): http://api.indeed.com/ads/apisearch?publisher=ID&q=java&l=austin%2C+tx&sort=&radius=&st=&jt=&start=&limit=&fromage=&filter=&latlong=1&co=us&chnl=&userip=1.2.3.4&useragent=Mozilla/%2F4.0%28Firefox%29&v=2

It works on localhost using simplexml_load_file. But returns false when I test it on live server. What's wrong?

This is their API doc: https://ads.indeed.com/jobroll/xmlfeed

ini_set('allow_url_fopen ','ON');

$xml = simplexml_load_file("http://api.indeed.com/ads/apisearch?publisher=ID&q=java&l=austin%2C+tx&sort=&radius=&st=&jt=&start=&limit=&fromage=&filter=&latlong=1&co=us&chnl=&userip=1.2.3.4&useragent=Mozilla/%2F4.0%28Firefox%29&v=2");

var_dump($xml);
Community
  • 1
  • 1
user10132
  • 3
  • 1
  • Is `simplexml` allowed on live server? – pes502 Mar 02 '14 at 11:06
  • Maybe you don't have the rights to set the `ini_set('allow_url_fopen ','ON');` on your webserver. – Shankar Narayana Damodaran Mar 02 '14 at 11:07
  • It doesn't work even without ini_set('allow_url_fopen ','ON'); BTW, I'm using Fatcow to host – user10132 Mar 02 '14 at 11:09
  • Well what is the error you get ? – Shankar Narayana Damodaran Mar 02 '14 at 11:11
  • Shankar, that's the problem. There's no error message. sipmlexml returns false. – user10132 Mar 02 '14 at 14:39
  • @user10132: Turn up error reporting to the highest level and log errors to file. Then follow the error log. Inside the error log you will see more information why that `FALSE` is there, why exactly loading of that file failed. See as well: [How to get useful error messages in PHP?](http://stackoverflow.com/q/845021/367456). The broad reason is already clear from what you report: It's a misconfiguration with your webserver. Most likely - as others have outlined - you're not allowed to use `http://` URLs with `simplexml_load_file` (and similar functions like `file_get_contents`). – hakre Mar 03 '14 at 15:59
  • I'm out of votes, suggested close reason: This question was caused by **a problem that can no longer be reproduced or a simple typographical error**. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting [the shortest program necessary to reproduce the problem](http://stackoverflow.com/help/mcve) before posting. – hakre Mar 03 '14 at 16:03

1 Answers1

0

I solved this problem by contacting my host, Fatcow, and they had a link where I could edit the phpinfo file. Turning the allow_url_fopen on solved the problem.

user10132
  • 3
  • 1