我有一个简单的搜索栏,用户输入搜索词,并且应该显示与搜索词匹配的推文。但是,它仅适用于单个单词搜索。
<div id="search">
<form action="" method="get">
<label>
Search:
<input type="text" name="search_box" id="search_box" />
<input type="submit" name="submit" id="submit" value="Search" />
</label>
</form>
</div>
<?php
$q=$_GET['search_box'];
$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 "<h3>Twitter search results for '".$q."'</h3>";
foreach ($search_res->entry as $twit1) {
$description = $twit1->content;
$message = $row['content'];
echo "<div class='text'>".$description."</div><br><br>";
}
curl_close($tw);
?>