0
我希望能夠做到以下幾點:傳遞變量到curl_setopt
$search_terms[0]='frank';
$search_terms[1]='sinatra';
$search_terms[2]='beyonce';
foreach($search_terms as $term){
$ch = curl_init();
$url ='http://search.twitter.com/search.json?q=' + $term +'&rpp=100';
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$var = curl_exec($ch);
curl_close($ch);
$obj = json_decode($var, true);
echo $term;
var_dump($obj);
}
但我得到一個空對象,當我傾倒$ OBJ,即使$長期版畫確定。
決不承擔EXEC()調用工作。之後你應該檢查$ var:'if($ var === FALSE){die(curl_error($ ch)); }'。 – 2011-05-13 21:10:09