0

Yahoo Shopping, really confused about User-Agen.

I am trying everything to get the cost of say 1 Dell computer, using PHP.

<?php

// Parsing Yahoo! REST Web Service results using
// unserialize. PHP4/PHP5
// Author: Jason Levitt
// February 1, 2006

error_reporting(E_ALL);

// output=php means that the request will return serialized PHP
$request = 'http://shopping.yahooapis.com/ShoppingService/v3/productsearch?appid=YahooDemo&category=Computers&query=dell&results=1&output=php';

$response = file_get_contents($request);

if ($response === false) {
die('Request failed');
}

$phpobj = unserialize($response);

echo '<pre>';
print_r($phpobj);
echo '</pre>';

?>

And I keep getting the error:[0] => User-agent not valid

And this happened when I tried to use DOM and XML. sad.gif Any solutions.

PS. Same thign happens if I use my own APPID key too.

by
1 Reply
  • Tried to just retrieve the file
    CODE
    <?php
    $request = 'http://shopping.yahooapis.com/ShoppingService/v3/productsearch?appid=K06FEt7V34FaT8M36dUa_MYTaBEu9jxjn1qr0ec277hH5czINOqTc8SMLH3oHv4l.EI-&category=Computers&query=dell&results=1';
    $response = file_get_contents($request);
    echo $response;
    ?>

    and get similar error: The following errors were detected: User-agent not valid
    0
  • QUOTE (quickercorp @ Jun 24 2009, 11:05 AM) <{POST_SNAPBACK}>
    I am trying everything to get the cost of say 1 Dell computer, using PHP.

    <?php

    // Parsing Yahoo! REST Web Service results using
    // unserialize. PHP4/PHP5
    // Author: Jason Levitt
    // February 1, 2006

    error_reporting(E_ALL);

    // output=php means that the request will return serialized PHP
    $request = 'http://shopping.yahooapis.com/ShoppingService/v3/productsearch?appid=YahooDemo&category=Computers&query=dell&results=1&output=php';

    $response = file_get_contents($request);

    if ($response === false) {
    die('Request failed');
    }

    $phpobj = unserialize($response);

    echo '<pre>';
    print_r($phpobj);
    echo '</pre>';

    ?>

    And I keep getting the error:[0] => User-agent not valid

    And this happened when I tried to use DOM and XML. :(u can get the user agent by $_SERVER['HTTP_USER_AGENT']
    0
  • $curl= curl_init();
    curl_setopt ($curl, CURLOPT_URL,$file_name);
    curl_setopt ($curl, CURLOPT_POST, 0);
    curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.1) Gecko/20090624 Firefox/3.5 (.NET CLR 3.5.30729)");
    $xml=curl_exec ($curl);

    This worked for me!
    0

Recent Posts

in General Discussion at YDN