Problema com API
Estou com um problema talvez simples ao usar a api do twitter para busca, quando dois termos são digitados na bloco de pesquisa por exemplo {a cozinha) a api me resulta o seguinte erro.
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in C:\Xampp\htdocs\RU\twitter.php:14 Stack trace: #0 C:\Xampp\htdocs\RU\twitter.php(14): SimpleXMLElement->__construct('') #1 {main} thrown in C:\Xampp\htdocs\RU\twitter.php on line 14
não sei o que fazer pois sou um pouco leigo nesta area, preciso da ajuda da cominidade,
<?php include('header.php'); ?>
<?php include('advertsing/adleft.php'); ?>
<div class="tweetresults">
<?php
$q=$_GET['q'];
if($_GET['q']==''){
$q = 'LadyGaga';}
$search = "http://search.twitter.com/search.atom?q=".$q."";
$tw = curl_init();
curl_setopt($tw, CURLOPT_URL, $search);
curl_setopt($tw, CURLOPT_RETURNTRANSFER, TRUE);
$twi = curl_exec($tw);
$search_res = new SimpleXMLElement($twi);
//Echo the Search Data
foreach ($search_res->entry as $twit1) {
$description = $twit1->content;
$description = preg_replace("#(^|[\n ])@([^ \"\t\n\r<]*)#ise", "'\\1<a href=\"http://www.twitter.com/\\2\" >@\\2</a>'", $description);
$description = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t<]*)#ise", "'\\1<a href=\"\\2\" >\\2</a>'", $description);
$description = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r<]*)#ise", "'\\1<a href=\"http://\\2\" >\\2</a>'", $description);
echo "<div class='tweetuser'><a href=\"",$twit1->author->uri,"\" target=\"_blank\"><img border=\"0\" class=\"tweetthumb\" src=\"",$twit1->link[1]->attributes()->href,"\" title=\"", $twit1->author->name, "\" /></a>\n";
echo "<div class='tweettext'>".$description."<div class='description'>From: ", $twit1->author->name,"</div></div><div class='tweettline'></div></div>";
}
curl_close($tw);
echo "<h2>Within this topic</h2>";
echo "<td>";
echo "<a>Keywords: </a>";
echo "<a href=''>Justin Bieber</a>, ";
echo "<a href=''>Demi Lovato</a>, ";
echo "<a href=''>Bella Swan</a>, ";
echo "<a href=''>Sirius Black</a>, ";
echo "<a href=''>Lady Gaga</a>";
echo "</td>";
echo "</div>";
?>
<div class='nospace'></div>
<?php include('advertsing/adrelated.php'); ?>
<?php include('footer.php'); ?>Discussão (1)
Carregando comentários...