Fetch tweets by twitter API

<?php
ini_set(‘display_errors’, 1);
require_once(‘TwitterAPIExchange.php’);

/** Set access tokens here – see: https://dev.twitter.com/apps/ **/
$settings = array(
‘oauth_access_token’ => “”,
‘oauth_access_token_secret’ => “”,
‘consumer_key’ => “”,
‘consumer_secret’ => “”
);

/** URL for REST request, see: https://dev.twitter.com/docs/api/1.1/ **/

$url = “https://api.twitter.com/1.1/statuses/user_timeline.json&#8221;;

$requestMethod = “GET”;

$getfield = ‘?screen_name=hitesh23355457&count=20’;

$twitter = new TwitterAPIExchange($settings);
$string=json_decode($twitter->setGetfield($getfield)->buildOauth($url,$requestMethod)->performRequest());
foreach($string as $s){
echo “tweets:-“.$s->text;
}
?>

 

Advertisements

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