Advanced Search

Results 1 to 2 of 2

Thread: file_get_contents() returns diff value on server and browser

  1. #1
    Join Date
    Feb 2007
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool file_get_contents() returns diff value on server and browser

    I want to get some xml data from another server and process it for my own page.

    So, to get startet I do something like this:
    PHP Code:
    $url 'http://picasaweb.google.com/data/feed/base/user/jonas.ellehauge?kind=photo&max-results=5&start-index=600&thumbsize=400';
    $xml file_get_contents($url);
    echo 
    $xml
    Which happens to return different xml compared to if I put the same URL in my browser - i.e. less xml without the links etc I am looking for.

    I tried extending it a bit, like this:
    PHP Code:
    $opts = array('http' =>
        array(
            
    'method'  => 'GET',
            
    'user_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1 (.NET CLR 3.5.30729)'
        
    )
    );
    $context stream_context_create($opts);
    $xml file_get_contents($urlnull$context);
    echo 
    $xml
    - pretending to be a browser. That doesn't work either.

    If I do it with a different webservice, i.e. this:
    PHP Code:
    $url "http://kort.arealinfo.dk/wms?service=wms&servicename=landsdaekkende_wms&VERSION=1.1.1&REQUEST=GetCapabilities"
    - It works fine - I get the same as I would in the browser.

    Any suggestions what I might do?

  2. #2
    Join Date
    Feb 2007
    Posts
    48
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I found the reason: I send an unauthenticated request to the Picasa feed from the server, but I was logged in to my Google account when viewing the feed in my browser.

    I feel rather silly not noticing by myself ..

Bookmarks

Posting Permissions

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