3

I used the following widget that does not work anymore. It displays the latest tweet from chosen twitter accounts in turn. I have consumer key, secret and access token but don't know how to add it to make the widget work.

<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&timestamp=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>
4

1 回答 1

0

似乎 twitter 完全弃用了 v 1。您是否尝试在此网址中设置 1.1 而不是 1? https://api.twitter.com/1/statuses/user_timeline/

从推特人那里检查一下:https ://dev.twitter.com/docs/api/1.1/overview

这也可能对您有用:

https://github.com/StanScates/Tweet.js-Mod

于 2013-07-19T21:33:03.490 回答