Rockstar Web Developer

How to fix the Twitter blogger.js script and make it work with the oAuth required by the v1.1 API

Published on August 13, 2013 by , in Javascript

Since the recent deactivation of the v.1 API of Twitter, the highly popular http://twitter.com/javascripts/blogger.js script was left nonfunctional.

There is a straightforward procedure to get it back running again by replacing

<script type="text/javascript" src="http://api.twitter.com/1/statuses/user_timeline.json?screen_name=screennamegoeshere&include_rts=1&count=1&callback=twitterCallback2"></script>

 

By a call to a .php file that generates the same thing, but while authenticating to the proper twitter application you will be creating.

You would need to mostly follow the steps illustrated here:
http://www.webdevdoor.com/php/authenticating-twitter-feed-timeline-oauth/

In short, here’s how you can get it up and running quickly:

1. Setup a twitter application at https://dev.twitter.com/apps/ (logging in with your own credentials). Save the consumer key & secret and access token & secret.

2. Download the TwitteroAuth library from here. You are only interested in the twitteroauth folder and it’s two files, which you will place next the .php script you are creating.

3. Create a twitterfeed.php file with the content provided in the tutorial, and fill in the variables (twitteruser / number of tweets and all the keys you’ve created at step 1):

You can download my version from here: http://cl.ly/code/1e1C3u2Z1U1c

I’ve only made an adjustment to the json_encode($tweets) part of the script by adding the twitterCallback2 which calls the old blogger script, which lets you use this cross-domain regardless of the server settings.

4. Upload the twitterfeed.php along the twitteroauth with the two files inside next to it to a server running PHP 5+.

5. Replace the old http://api.twitter.com/1/statuses/user_timeline.json call by one pointing to your newly created .php file, like this:

<script type=”text/javascript” src=”http://yourdomain.com/twitterfeed.php”></script>

FavoriteLoadingAdd to favorites

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent writings