Henrik Petterson
Henrik Petterson

Reputation: 7094

Displaying Twitter feed stopped working

The default way to display a twitter feed has stopped working. 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. I created a fiddle in case you want to play: http://jsfiddle.net/9EvXn/

Upvotes: 11

Views: 16183

Answers (4)

afroginthevalley
afroginthevalley

Reputation: 39

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).

All calls must now be made the API.twitter.com and using the versionned endpoint (/1.1 ideally, or /1 until March 2012).

Upvotes: 0

Gary Woods
Gary Woods

Reputation: 1011

You need to update your code to Twitter's new 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

Upvotes: 14

powerbuoy
powerbuoy

Reputation: 12838

Someone recently wrote this on my blog (as a comment to an article on displaying Twitter feeds):

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. 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=?';

So perhaps just slap "api" in front of "twitter.com". And the /1/ I assume is a version number.

Edit: Apparently this was correct :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>

Upvotes: 3

yodog
yodog

Reputation: 6232

looks ok to me.

here, i created a jsfiddle to test: http://jsfiddle.net/RASG/ULZBB/

try editing my jsfiddle, and see if it can help you.

Upvotes: 1

Related Questions