All TalkersCode Topics

Follow TalkersCode On Social Media - A Social Media Network for developers Join Now ➔

Display Latest Twitter Status Using PHP

Last Updated : Jul 1, 2023

IN - PHP | Written & Updated By - Amruta

In this tutorial we will show you how to display your latest twitter status using PHP. There are many websites which uses this feature in their website to keep updated their user from latest status of website on twitter.

You may also like Login With Twitter Using PHP.

Display Latest Twitter Status Using PHP

To Display Latest Twitter Status It Takes Only Two Steps:-

  1. Create a Twitter app and get all the details
  2. Make a PHP file to display twitter status

Step 1. Create a Twitter app and get all the details

You have to create an application on twitter from here

Then you need to collect API keys, API secrets and your access token, access token secret.You also need to download Twitter Outh PHP Library to get your latest status from twitter.

Step 2. Make a PHP file to display twitter status

We make a PHP file and save it with a name status.php

<div id="wrapper">


$twitter_customer_key = 'Your API Key';
$twitter_customer_secret = 'Your API Secret';
$twitter_access_token = 'Your Access Token Key';
$twitter_access_token_secret = 'Your Access Token Secret';

$connection = new TwitterOAuth($twitter_customer_key, $twitter_customer_secret, $twitter_access_token, $twitter_access_token_secret);

$my_tweets = $connection->get('statuses/user_timeline', array('screen_name' => 'Your Name', 'count' => 1));

echo '<div class="twitter-bubble">';

 echo 'Error :'. $my_tweets->errors[0]->code. ' - '. $my_tweets->errors[0]->message;
 echo $my_tweets[0]->text;
echo '</div>';


In this step we insert twitter outh library which is required to get your latest status and then we add all our details like keys and secrets then we create a object of TwitterOAuth by passing all the details in it and then we get and display our latest status or tweets from twitter.

Thats all, this is how to display latest twitter status using PHP.You can customize this code further as per your requirement. And please feel free to give comments on this tutorial.

I hope this tutorial on display tweets php helps you and the steps and method mentioned above are easy to follow and implement.

Author Image About Amruta

Amruta is an Experienced web developer with 4 years for experience she completed her master's with MCA and passionate about programming Languages for creating technical contents like HTML, CSS, JavaScript, Java, Python, PHP, jQuery.

Follow Amruta On Linkedin 🡪