简体   繁体   English

显示Twitter Feed停止工作

[英]Displaying Twitter feed stopped working

The default way to display a twitter feed has stopped working. 显示Twitter Feed的默认方式已停止工作。 Here is an example code: 这是一个示例代码:

<html>
    <head>
        <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
    </head>
    <body>
        The feed should display below:
        <div id="twitter_update_list"> </div>
        <script type="text/javascript" src="http://twitter.com/statuses/user_timeline/stackoverflow.json?callback=twitterCallback2&amp;count=4">
    </body>
</html>

Why is this not working? 为什么这不起作用? I suspected that the issue was on Twitter's end but this has not functioned for a while now. 我怀疑这个问题是在Twitter的结尾,但现在已经有一段时间没有运作了。 I created a fiddle in case you want to play: http://jsfiddle.net/9EvXn/ 如果你想玩,我创造了一个小提琴: http//jsfiddle.net/9EvXn/

You need to update your code to Twitter's new API. 您需要将代码更新为Twitter的新API。 This code will work: 此代码将起作用:

<html>
    <head>
        <script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
    </head>
    <body>
 <div id="twitter_update_list"></div>
            <script type="text/javascript" src="http://api.twitter.com/1/statuses/user_timeline.json?screen_name=stackoverflow&include_rts=true&count=4&callback=twitterCallback2"></script>
</div>
    </body>
</html>

Pay attention to this line of code that is updated: 请注意更新的这行代码:

http://api.twitter.com/1/statuses/user_timeline.json?screen_name=stackoverflow&include_rts=true&count=4&callback=twitterCallback2

Someone recently wrote this on my blog (as a comment to an article on displaying Twitter feeds): 最近有人在我的博客上写了这篇文章(作为对显示Twitter提要的文章的评论):

Just a heads up, if you are using this code I've noticed that it stopped working recently. 只是抬头,如果你使用这个代码,我注意到它最近停止了工作。 I believe it is due to Twitter's new API. 我相信这是由于Twitter的新API。 The culprit is the url that fetches the tweets. 罪魁祸首是获取推文的网址。 here is an updated url that seems to fix the issue: var url = 'http://api.twitter.com/1/statuses/user_timeline.json?screen_name=' + username + '&count=' + limit + '&callback=?'; 这是一个更新的网址,似乎解决了这个问题: var url = 'http://api.twitter.com/1/statuses/user_timeline.json?screen_name=' + username + '&count=' + limit + '&callback=?';var url = 'http://api.twitter.com/1/statuses/user_timeline.json?screen_name=' + username + '&count=' + limit + '&callback=?';

So perhaps just slap "api" in front of "twitter.com". 所以也许只是在“twitter.com”面前拍打“api”。 And the /1/ I assume is a version number. 并且/ 1 / I假设是版本号。

Edit: Apparently this was correct :P 编辑:显然这是正确的:P

<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
<div id="twitter_update_list"></div>
<script type="text/javascript" src="http://api.twitter.com/1/statuses/user_timeline.json?screen_name=stackoverflow&include_rts=true&count=4&callback=twitterCallback2"></script>

looks ok to me. 看起来对我好

here, i created a jsfiddle to test: http://jsfiddle.net/RASG/ULZBB/ 在这里,我创建了一个jsfiddle进行测试: http//jsfiddle.net/RASG/ULZBB/

try editing my jsfiddle, and see if it can help you. 尝试编辑我的jsfiddle,看看它是否可以帮助你。

This is part of Twitter's latest API updates, announced previously (see https://dev.twitter.com/blog/api-housekeeping and https://dev.twitter.com/docs/deprecations/spring-2012 ). 这是Twitter之前宣布的最新API更新的一部分(请参阅https://dev.twitter.com/blog/api-housekeepinghttps://dev.twitter.com/docs/deprecations/spring-2012 )。

All calls must now be made the API.twitter.com and using the versionned endpoint (/1.1 ideally, or /1 until March 2012). 现在必须将所有呼叫都设置为API.twitter.com并使用版本化端点(理想情况下为/1.1,或者直到2012年3月为/ 1)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM