Getting twitter messages on PHP

It’s usual on web sites to place a widget with twitter messages by site owner. There are many methods to get messages from Twitter. For example you can do it using Twitter API.

There is another very simple method. It’s possible to get the messages via RSS.

The page contains RSS feed of tweets by me.

http://twitter.com/statuses/user_timeline/adilaliyev.rss



On PHP you can get the contents of RSS with a help of cURL:

<?php
// create a new cURL handle
$ch = curl_init();
 
// set RSS URL
curl_setopt($ch, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/adilaliyev.rss");
 
// set additional options
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
// get the contents
$a = curl_exec($ch);
 
echo ($a);
 
// close cURL handle
curl_close($ch);
?>

After getting the RSS feeds you can manipulate it using XML Features of PHP.

Facebook comments:

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">