通过推特搜索不工作获取最新推文



我使用以下代码从特定的标签

获取最新的tweet
$(document).ready(function(){
getLatestTweets();
function getLatestTweets(){
    var url = "http://search.twitter.com/search.json?q=%23syria&result_type=recent&rpp=3&callback=?";
    $.getJSON(url, function(json){
        alert('reached');
        var html = '<ul>';
        $.each(json.results, function( key, result){
            html += '<li><a href="#">' + '> ' + result.text + ' ...' + '</a></li>'; 
        });
        html += '</ul>';
        $('#archive-twitter').append(html);
    });
}
});  

这段代码两天前还能正常工作,但今天停止工作了。现在getJSON方法不会成功,即使当我使用以下链接

http://search.twitter.com/search.json?q=%23syria& result_type = recent& rpp = 3

浏览器中的

我得到实际的json数据

我不知道是什么问题?

更新:我添加了一个测试链接来澄清问题http://latakiancoder.com/twitter-test.php

我已经尝试代理服务器端请求和工作:

JS代码:

$(document).ready(function(){
                getLatestTweets();
                function getLatestTweets(){
                    var url = "http://search.twitter.com/search.json?q=%23syria&result_type=recent&rpp=3";
                    $.getJSON("proxy.php", { url: url }, function(json){
                        var html = '<ul>';
                        $.each(json.results, function( key, result){
                            html += '<li><a href="#">' + '> ' + result.text + ' ...' + '</a></li>'; 
                        });
                        html += '</ul>';
                        $('#archive-twitter').append(html);
                    });
                }
            });  

proxy.php代码:

<?php
    $url = $_GET['url'];
    $json = file_get_contents($url);
    echo $json;
?>

你的URL在我这边工作正常。

确保include_entities设置为true以获得标签结果。

http://search.twitter.com/search.json?q=ipl& result_type = recent& include_entities = true

查看了上面的url响应Header:

X-Frame-Options SAMEORIGIN
X-XSS-Protection    1; mode=block

似乎twitter已经退役了API v1

最新更新