PHP ile Yahoo BOSS API çıktı XML

0 Cevap php

Ben şimdiye kadar bu kodu almak başardı:

    <?php
//Gather data and prepare query
$thequery = urlencode($_GET['s']);
$yhost = 'http://boss.yahooapis.com';
$apikey = 'xxxxxxxxxxxxxxx';
$url = $yhost.'/ysearch/news/v1/'.$thequery.'?appid='.$apikey.'&format=xml';
//Get the results
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
$results = new SimpleXmlElement($data, LIBXML_NOCDATA);
//echo the results
foreach ($results->resultset_news->result as $theresult) {
echo '<a href="'.$theresult->clickurl.'">'.$theresult->title.'</a><br/>';
echo $theresult->abstract.'<br/>';
echo '<small><i>'.$theresult->dispurl.'</i></small><br/>';
echo '<br/><br/>';
}

Peki tam HTML yerine i çıkış gerçek XML do?

0 Cevap