NameSilo

PHP, XML and the yahoo api

Spaceship Spaceship
Watch

w1ww

Established Member
Impact
9
Hi :)

I'm trying to use the yahoo search api, that returns a XML file and I've this script to phrase the XML, but the script returns a blank screen:
You can see an example of what the yahoo returns here: http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=YahooDemo&query=madonna&results=2

And the PHP code is here:

PHP:
<?php

$key = "MYKEY";
$query = "something";
$language = "en";



$url = "http://search.yahooapis.com/WebSearchService/V1/webSearch?appid=".$key."&query=".$query."&results=10&language=".$language."";



$count = 10; 
        //* get the xml file
        $xml = simplexml_load_file($url);
        //* phrase all the data from the xml so we can display it
            for ($x = 0; $x < $count; $x++) {
             //* this bits for if its an rss 1 feed
            if (isset($xml->item)) {
                $item = $xml->item[$x];
            }
            //* this bits for 0.91 rss feeds
                elseif (isset($xml->Result->item)) {
                $item = $xml->Result->item[$x];
            }
            //* show the headline and the description
                echo "<a href=\"$item->Url\">$item->Title</a><br>$item->Summary<br><br>";
        }
        //* reset variables
        unset($xml);
        unset($item);
//* close the function loop




?>

Thanks for the help! :)
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable DomainsUnstoppable Domains
PM sent
 
0
•••

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back