www.webdeveloper.com
Results 1 to 3 of 3

Thread: Loading from URL

Hybrid View

  1. #1
    Join Date
    Aug 2004
    Location
    Florianópolis
    Posts
    267

    Loading from URL

    Hi,

    I am having a issue with the following code

    PHP Code:
    <?php


    $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'
        } 
        else 
        { 
            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

  2. #2
    Join Date
    Mar 2014
    Posts
    40
    Your url seems to be a JSON and not a XML file.

  3. #3
    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);

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles