我使用了以下不再起作用的小部件。它依次显示所选Twitter帐户的最新推文。我有消费者密钥,秘密和访问令牌,但不知道如何添加它以使小部件工作。
<script><!--
var feed = ["david_garrett", "50cent", "shemarmoore"];
var refresh = 20;
var direction = 0;
window.onload = function()
{
var scriptTag = document.createElement("script");
var location = (feed.constructor == Array) ? feed[Math.floor(Math.random() * feed.length)] : feed;
scriptTag.setAttribute("src", "https://api.twitter.com/1/statuses/user_timeline/" + location + ".json?callback=retrieveData&count=1×tamp=no");
document.getElementsByTagName("body")[0].appendChild(scriptTag);
setTimeout("location.reload();", refresh * 1000);
}
function retrieveData(twitters)
{
var tweet = document.getElementById("u");
tweet.innerHTML = "<span><b>" + twitters[0].user.screen_name + "</b><br/>" + twitters[0].text + "</span>";
if (tweet.scrollHeight > tweet.clientHeight)
setTimeout(scrollWindow, 5000);
}
function scrollWindow()
{
var tweet = document.getElementById("u");
if (direction == 0)
tweet.scrollTop++;
else
tweet.scrollTop--;
if (tweet.scrollTop + tweet.clientHeight >= tweet.scrollHeight)
{
direction = 1;
setTimeout(scrollWindow, 5000);
}
else if (tweet.scrollTop <= 0)
{
direction = 0;
setTimeout(scrollWindow, 5000);
}
else
{
setTimeout(scrollWindow, 100);
}
}
//-->
</script>
答案 0 :(得分:0)
从twitter人员那里查看:https://dev.twitter.com/docs/api/1.1/overview
这也可能对您有用: