0

I am having a problem with parsing an API which was working fine till yesterday!

The code snippet :

$checkurl = "http://api1.webpurify.com/services/rest/?method=webpurify.live.check&api_key=&text=".urlencode('test test test');

$response = simplexml_load_file($checkurl,'SimpleXMLElement', LIBXML_NOCDATA);

The problem is simplexml_load_file() is not returning any value and loads forever!

6
  • Did you try to simply download the file and load it from a local file rather than remotely? Commented May 15, 2012 at 2:37
  • No Michael. Can you guide me through the process? Just surprised because this was working fine till yesterday and nothing as changed in the code as well. Commented May 15, 2012 at 2:39
  • Just open the url in your browser and see if you get what you expect. If it is taking forever to load ( and probably eventually timing out) it is possible that your packets are being dropped either by your server's outbound firewall, or the XML file's server's inbound firewall. Commented May 15, 2012 at 2:41
  • Yep. It loads fine in the browser. Thanks Mike! will check that! :) Commented May 15, 2012 at 2:43
  • lol will change the API key soon :) Commented May 15, 2012 at 2:49

1 Answer 1

2

This is not a SimpleXML problem, but most likely occurs because the download is being blocked somehow.

Open up your browser and try to access the URL first; if you can download the file properly, save it and run it through SimpleXML again. That would eliminate at least one factor.

Sign up to request clarification or add additional context in comments.

2 Comments

+1. The example code runs in my environment without issue, suggesting the issue is network related.
That seems to be the problem. Will check with my server administrator.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.