Loading from URL
I am having a issue with the following code
$url = 'http://api.tumblr.com/v2/blog/myblog.tumblr.com/info?api_key=01010010100101';
if( ! $xml = simplexml_load_file($url) )
echo 'unable to load XML file';
echo 'XML file loaded successfully';
I keep getting the message "unable to load XML file" no matter how I try different approaches to make the code work.
Anyone could give me a little help ?
Thanks in advance
Your url seems to be a JSON and not a XML file.
The problem is that your URL that you are loading is JSON file not xml file. So to load JSON file use something like:
$variable = file_get_contents('http://example.com/data.json');
$decoded = json_decode($variable);