Twitter Display Code No Longer Working

Hi,

I have a code which displays the Tweets from my Twitter profiles however they have stopped working. I had the same code working on another site and this has also stopped working.

	 <script src="http://twitter.com/javascripts/blogger.js" type="text/javascript">
</script>

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

</script>

	</div>

I discovered exactly the same problem on one of my sites yesterday. It’s because Twitter retired version 1 of their API on Tuesday. Now all requests have to be made via version 1.1 of the API, which unfortunately requires authentication now for all requests.

At this point, you have two options really… you can use one of the timeline widgets that Twitter provide (the easiest option), or you’ll need to set up some server side code (ie. PHP or similar) to do the API authentication.

Thanks,

How do I find the Twitter widgets. But personally I think they are messy.

Is there are a replacement for the code they retired?

Hi Justlukeyou - login to Twitter then go to https://twitter.com/settings/widgets to manage and create new widgets.

Thanks,

I have looked from through them. Are there any minimalist widgets? The Twitter ones look clunky and overbearing.

Sorry, probably can’t help you too much further - there’s this link - which gives an overview of the new set up.

Just to make sure we’re on the right wave length, the following code would be for my site - is this the same code you feel is too “clunky”:

<a class=“twitter-timeline” href=“https://twitter.com/Easy_Bingo” data-widget-id=“345256637520551936”>Tweets by @Easy_Bingo</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?‘http’:‘https’;if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+“://platform.twitter.com/widgets.js”;fjs.parentNode.insertBefore(js,fjs);}}(document,“script”,“twitter-wjs”);</script>

if you do find an answer to this, let me know, i would also be interested to hear this.

Twitter has turned off their old API - to use the new one, you must go to the twitter development site and create an app for your account. This is give you the keys you need to perform Oauth.

Once you have them, you can access your tweets via PHP - here is the code I use to read my tweets and store them in a MySQL table for future processing.

You will need to download the twitteroauth.php library for this to work.

<?php
require_once(“twitteroauth.php”);
$twitter_un = “Your-Account_Name”;
$num_tweets = 10;
$consumerkey = “xxxxxxxxxxxxxxx”;
$consumersecret = “xxxxxxxxxxxxxxxxxxxxxxxxx”;
$accesstoken = “xxxxxxxxxxxxxxxxxxxxxxxxx”;
$accesstokensecret = “xxxxxxxxxxxxxxxxxxxxxxxx”;
$connection = new TwitterOAuth($consumerkey, $consumersecret, $accesstoken, $accesstokensecret);
$tweets = $connection->get(“https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=“.$twitter_un.”&count=”.$num_tweets);
$dbconn=@mysql_connect(“localhost”,“username”,“password”) or die(mysql_error());
@mysql_select_db(“database-name”,$dbconn);
foreach($tweets as $tweet) {
$entry = $tweet->text;
$entry = addslashes(trim(substr($entry, 0, 300)));
$sql = “SELECT * FROM twitterfeed WHERE tweet=‘$entry’”;
$result = @mysql_query($sql) or die(mysql_error());
$rr = mysql_num_rows($result);
if ($rr == 0)
{
$sql = “INSERT INTO twitterfeed(tweet) VALUES(‘$entry’)”;
$results = @mysql_query($sql);
}
}
mysql_close($dbconn);
?>

I can’t customize the widget. Is there a way to customize it? It’s ugly white or dark background? wtf?