Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

get twitter updates question [php]

  • 23-07-2011 07:06PM
    #1
    Registered Users, Registered Users 2 Posts: 648 ✭✭✭


    hi

    im using php and curl to get twitter updates of a specific user

    however i want to know if i can get the updates of several users in one call to twitter ?

    tnx




    heres an example of the curl script im using :

    [PHP]
    function get_status($twitter_id, $hyperlinks = true) {
    $c = curl_init();
    curl_setopt($c, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/$twitter_id.xml?count=1");
    curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
    $src = curl_exec($c);
    curl_close($c);
    preg_match('/<text>(.*)<\/text>/', $src, $m);
    $status = htmlentities($m[1]);
    if( $hyperlinks ) $status = ereg_replace(":alpha:+://[^<>[:space:]]+[[:alnum:]/]", '<a href="%5C%22%5C%5C0%5C%22">\\0</a>', $status);
    return($status);
    }
    [/PHP]
    Tagged:


Comments

  • Registered Users, Registered Users 2 Posts: 26,449 ✭✭✭✭Creamy Goodness


    don't think you can make multiple user requests to twitter like you want to.

    stick it in a loop like so.

    [php]
    $twitterUsers = array('stephenfry', 'ladygaga', 'boards_ie'); //etc.

    $results = array();
    foreach($twitterUsers as $tweeter)
    {
    $results[$tweeter] = get_status($tweeter);
    }

    print_r($results);
    [/php]


  • Registered Users, Registered Users 2 Posts: 182 ✭✭fugee


    why not use the twitter widget

    http://twitter.com/about/resources/widgets/widget_search

    Very neat and updates as often as you set.


Advertisement