fastread homefastrread library fastread menu

PHP Tutorial : Show Twitter feed in Webpage

Tutorial by:Admin      Date: 2016-04-14 02:31:58

❰ Previous Next ❱

Though Twitter has lunched API Ver1.1, most of the application developed in older version API will not work, You need to migrate your application to Ver1.1 and which requires Authentication on all endpoints and support JSON only. Lets discuss how to display User feeds from Twitter in you website.

The first thing you need to create an application in twitter and get the following
 - oauth access token
 - oauth access token secret
 - consumer key
 - consumer secret
This you can create in, by using your twitter user name and password.

Then you need TwitterAPIExchange.php class file which you can download from here.

Now copy paste the following code to get user Twitter Feeds.


$settings = array(
'oauth_access_token' => "Enter Your Access Token",
'oauth_access_token_secret' => "Enter Your Token Secret",
'consumer_key' => "Enter Your Consumer Key",
'consumer_secret' => "Enter Your Consumer Secret"

$url = '';
$getfield = '?screen_name=a2zwebhelp';
$requestMethod = 'GET';

$twitter = new TwitterAPIExchange($settings);
$response = $twitter->setGetfield($getfield)
->buildOauth($url, $requestMethod)

/* Here you will get all info from user timeline */

Copy/ paste the following code to display user feeds

$valid_data = json_decode($response); //JSON data to PHP.
print "<ul>";
  foreach ($valid_data as $key=>$value) {
    print "<li>";
    print $value->text;
    print "</li>";
print "</ul>";

❰ Previous Next ❱

PHP Tutorial

Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website