SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    730
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    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.

    Code:
    	 <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>

  2. #2
    SitePoint Mentor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,256
    Mentioned
    32 Post(s)
    Tagged
    4 Thread(s)
    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.

  3. #3
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    730
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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?

  4. #4
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Justlukeyou - login to Twitter then go to https://twitter.com/settings/widgets to manage and create new widgets.
    Last edited by DaveMaxwell; Jun 13, 2013 at 11:53. Reason: removed unneeded links

  5. #5
    SitePoint Guru
    Join Date
    Feb 2007
    Posts
    730
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Thanks,

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

  6. #6
    SitePoint Member
    Join Date
    Jun 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  7. #7
    SitePoint Member
    Join Date
    Jun 2013
    Location
    Canada
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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);
    ?>

  8. #8
    SitePoint Zealot naynay99's Avatar
    Join Date
    Jan 2010
    Location
    Los Angeles
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't customize the widget. Is there a way to customize it? It's ugly white or dark background? wtf?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •