How to display tweets from Twitter on your website?

If you tweet a lot on Twitter and wish to display them on your website or blog then you can do that easily with the following code


$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, “”);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERPWD, “<username>:<password>”);

$str = curl_exec($ch);

echo $str;


Once you get your tweets you can then customize the look and feel accordingly or save them in the database. Please note that you will need to enter the username and password of your Twitter account other wise the above will not work.

Hope the above helped

Leave a Comment