Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2005
    Posts
    4,486
    Tokens
    921

    Latest Awards:

    Default Twitter latest tweet Q's

    I've been using the following PHP code (not made by me) to display my latest twitter tweets on my site. I got two questions for you guys about the code today;

    1. Is there a better and easier way to code the same thing, still in PHP
    2. If twitter is offline, the script will stop the rest of my page from loading. Is there a way to make the rest of my page continue loading if twitter is offline, and show a message to say twitter is offline.

    Code:
                <?php
                function getTweet($url) {
                $feed = file_get_contents($url);
                $xml = new SimpleXMLElement($feed);
                $tweet = $xml->entry->title;
                return $tweet;
                }
                
                $username = "TomSpit";
                $url = "http://search.twitter.com/search.atom?q=from:".$username."&rpp=1";
                
                echo "<a href=\"http://twitter.com/tomspit/\" onclick=\"window.open(this); return false;\">";
                echo getTweet($url);
                echo "</a>";
                ?>
    All help receives a +REP. Tom.
    "RETIRED" FROM HABBO(X)

    :¬:

    TOMSPIT / COWLY05


  2. #2
    Join Date
    Mar 2009
    Location
    Western Australia
    Posts
    386
    Tokens
    0

    Default

    Sure is http://twitter.com/goodies/widgets go to "my website" then just do plain HTML or choose a design.

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

    Latest Awards:

    Default

    PHP Code:
    <?php
    $username 
    "dentafrice";

    $url "http://twitter.com/statuses/user_timeline/{$username}.xml?count=1";
    $get = @file_get_contents($url);

    if(
    $get) {
        
    // did load the page..
        
    $status = new SimpleXMLElement($get);
        echo 
    $status->status[0]->text;
    }

Posting Permissions

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