Get Twitter Statuses With curl()

1 08 2010

function get_twitter_status() {
  $status_list = array();
  $c = curl_init();
  curl_setopt($c, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/phoenixblue.xml?count=10");
  // count = number of statuses to grab
  curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt ($c, CURLOPT_CONNECTTIMEOUT, 20);
  curl_setopt($c, CURLOPT_TIMEOUT,5);
  $src = curl_exec($c);
  $xmlList = new SimpleXMLElement($src);
  foreach($xmlList->status as $xml) {
    $text = (string)$xml->text;
    $status_list[] = $text;
  }
  if(count($status_list) $status_list[] = $xmlList->error;
  return $status_list;
}

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: