Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    529
    Tokens
    0

    Default Getting latest twitter status

    I wrote a little bit of PHP code for no reason and decided to give it out for free. It's really simple and it all does is grabs your latest tweet using the Twitter Search and then echo's it. This could be used to make something like a status signature or whatever if you just then made the value of $tweet into an image. Anyway, I'm not writing that but if you wish to, enjoy yourself.

    PHP Code:
    <?php
        
        
    // The function that will do the grabbing of the tweet
        
    function getTweet($url) {
        
            
    // Get the contents of the ATOM file
            
    $feed file_get_contents($url);
            
    // Make an XML instance of it
            
    $xml = new SimpleXMLElement($feed);
            
            
    // Using the XML get the tweet, for this we needed to work out the xml structure
            
    $tweet $xml->entry->title;
            
            return 
    $tweet;
        
        }

        
    // $username is your twitter username
        
    $username "cleanString";
        
        
    // This is the API call URL. &rpp=1 means we will only get the latest status
        
    $url "http://search.twitter.com/search.atom?q=from:".$username."&rpp=1";
        
        
    // Use our function we made earlier to grab our latest tweet and echo it
        
    echo getTweet($url);
        
    ?>

  2. #2
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    I really don't get why people don't use the public twitter API instead of parsing pages/search feeds ;s.

  3. #3
    Join Date
    Jul 2007
    Location
    Scotland
    Posts
    529
    Tokens
    0

    Default

    I don't know, I just am used to using this. Sure it would be easier to use the public API but where would the fun in that be when you're writing random code chunks.

  4. #4
    Join Date
    May 2007
    Location
    Westmid
    Posts
    349
    Tokens
    0

    Default

    This dont work mate?

    Well it didnt for me :S

    entry->title; return $tweet; } // $username is your twitter username $username = "tomtomdjin"; // This is the API call URL. &rpp=1 means we will only get the latest status $url = "http://search.twitter.com/search.atom?q=from:".$username."&rpp=1"; // Use our function we made earlier to grab our latest tweet and echo it echo getTweet($url); ?>

    thats what came up in browser

  5. #5
    Join Date
    Mar 2008
    Posts
    5,108
    Tokens
    3,780

    Latest Awards:

    Default

    Quote Originally Posted by .:Tom-:. View Post
    This dont work mate?

    Well it didnt for me :S

    entry->title; return $tweet; } // $username is your twitter username $username = "tomtomdjin"; // This is the API call URL. &rpp=1 means we will only get the latest status $url = "http://search.twitter.com/search.atom?q=from:".$username."&rpp=1"; // Use our function we made earlier to grab our latest tweet and echo it echo getTweet($url); ?>

    thats what came up in browser
    Did you save it as .php..?

    I'd rather use the public API to do it, but this is a nice way too

  6. #6
    Join Date
    May 2007
    Location
    Westmid
    Posts
    349
    Tokens
    0

    Default

    Ahh,

    Fixxed

Posting Permissions

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