Twitter Search - Multiple searches based on CSV in Text file
I have a log file which stores search terms I want to run agasint a twitter search.
I have the following which basically searches for 1 value, however the CSV contains a number of values to search.
How can I adjust the below to find the file: searchterms.txt
Read in the comma seperated values, then search each one independantly.
Also save each search to its own text file?
<?php
$q=$_GET['q'];
if($_GET['q']==''){
$q = 'tpid1262445133';}
$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);
foreach ($search_res->entry as $twit1) {
$description = $twit1->content;
$date = strtotime($twit1->updated);
$message = $row['content'];
echo $twit1->author->ur开发者_如何学Goi;
echo " ";
echo $twit1->author->name;
echo " ";
echo $description;
echo "</br>";
}
curl_close($tw);
?>
$searches = explode(';', file_get_contents('searchterms.txt'));
foreach ($searches as $search) {
$result_array[] = json_decode(file_get_contents('http://search.twitter.com/search.json?q='.$search));
}
print_r($result_array);
精彩评论