Using a web service feed under REST is useful to obtain information that would otherwise be tricky to get.
For example, to get information out of Technorati (rankings etc) you could use:
$request = 'http://api.technorati.com/bloginfo?key=[key]&url=’ . urlencode(’www.jasonslater.co.uk’) . ”;
$response = file_get_contents($request);
(remember to replace the url with your own and put your API key in the section [key].
Alternatively, using the Yahoo model an example request could be something like:
$request = 'http://search.yahooapis.com/ ImageSearchService/V1/imageSearch?appid=YahooDemo& query='.urlencode('Al Gore').'&results=8';
After the data is parsed into elements check if you have simpleXML installed using php_info();
$phpobject = simplexml_load_string($response);
foreach($phpobject->attributes() as $name=>$attr)
{
$res[$name]=$attr;
}
print_r($phpobject);
var_dump($phpobject);
1 response so far ↓
1 Micromicon Blog » Blog Archive » Blogosphere technology posts for 31st March 2008 // Mar 31, 2008 at 4:10 pm
[...] PHP: Web Service Feed Information [...]
Leave a Comment