所以我正在尝试创建一个滚动的Twitter提要。我按照本教程中的说明进行操作。
它无法正常工作。开始加载然后变白。我注意到评论中有一些建议如何纠正问题,我认为我已经正确实施了,但它仍然无效。如果有人熟悉这个,那么需要从原始代码更改哪些代码才能使其生效?
我认为这与此有关:
// This replaces the <p>Loading...</p> with the tweets
insertLatestTweets: function (username) {
var limit = 5; // How many feeds do you want?
var url = 'http://api.twitter.com/1/statuses/user_timeline.json?screen_name= + username + '&count=' + limit + '&callback=?';
// Now ajax in the feeds from twitter.com
$.getJSON(url, function (data) {
// We'll start by creating a normal marquee-element for the tweets
var html = '<marquee behavior="scroll" scrollamount="1" direction="left">';
// Loop through all the tweets and create a link for each
for (var i in data) {
html += '<a href="http://twitter.com/' + username + '#status_' + data[i].id_str + '">' + data[i].text + ' <i>' + Twitter.daysAgo(data[i].created_at) + '</i></a>';
}
html += '</marquee>';
答案 0 :(得分:0)
以下是可能对您的方案有用的Twitter代码段。
<a class="twitter-timeline" href="https://twitter.com/ESPNcricinfo/cricketers-on-twitter"
data-widget-id="286832583709442048" style="width:320px; margin-bottom:20px;
height:290px;" width="320" height="290" data-theme="light"
data-link-color="#0084B4">Tweets from @ESPNcricinfo/cricket-tweeters</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)
[0];if(!d.getElementById(id)){
js=d.createElement(s);js.id=id;
js.src="//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js,fjs);}}
(document,"script","twitter-wjs");
</script>
答案 1 :(得分:0)
Twitter已经弃用了您尝试使用的API版本。
{"errors": [{"message": "The Twitter REST API v1 is no longer active. Please migrate to API v1.1. https://dev.twitter.com/docs/api/1.1/overview.", "code": 68}]}