0

我正在尝试使用 twiiter api 通过 cURL 在 php 中使用以下代码获取推文,但它似乎总是返回 NULL。

//$urlfetch = "https://search.twitter.com/search.json?q= geocode:".round($_GET['param1'],4).",".round($_GET['param2'],4).",25mi"; 

$urlfetch = "https://api.twitter.com/1/geo/search.json?query=Toronto"; 

    echo urlencode($urlfetch);
    echo $urlfetch;

    $ch = curl_init();
    $timeout = 30; // set to zero for no timeout
    curl_setopt ($ch, CURLOPT_URL, $urlfetch);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    curl_setopt ($ch, CURLOPT_PROXY, "10.3.100.209:8080");
    $response = curl_exec($ch);
    curl_close($ch);
    echo "<br />";
    var_dump($response);
    $response = json_decode($response);
    echo "<br />";
    var_dump($response);

编辑:对于 $urlfetch = " https://search.twitter.com/search.json?q=%20geocode:40.7,73.9,25mi "; 使用同一代理从浏览器输入时在http://pastebin.com/jQ9S2gV4处响应。

4

0 回答 0