How To Get Latest Tweets From Twitter

Get You Latest Tweets From Your Twitter Account…………….

Code

$value){
$r[] = “$key=” . rawurlencode($value);
}
return $method.”&” . rawurlencode($baseURI) . ‘&’ . rawurlencode(implode(‘&’, $r));
}

function buildAuthorizationHeader($oauth) {
$r = ‘Authorization: OAuth ‘;
$values = array();
foreach($oauth as $key=>$value)
$values[] = “$key=\”” . rawurlencode($value) . “\””;
$r .= implode(‘, ‘, $values);
return $r;
}
$url = “https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=TheStoveYard&count=2”;
$oauth_access_token = “54815118-O72leCQbG6jjGaMQh6HmuEx9pfl4gUUXDerYRaic”;
$oauth_access_token_secret = “PMQE9JKBnPofSVLh2hGvyvhCw097Ta4xnywvWDks”;
$consumer_key = “V32Tr1CHoJqkjbZFkzvjA”;
$consumer_secret = “gDPCzcljImi3t5VzxVs0ybAjDhpOZn681L0aJjJ7Os”;

$oauth = array( ‘oauth_consumer_key’ => $consumer_key,
‘oauth_nonce’ => time(),
‘oauth_signature_method’ => ‘HMAC-SHA1’,
‘oauth_token’ => $oauth_access_token,
‘oauth_timestamp’ => time(),
‘oauth_version’ => ‘1.0’);

$base_info = buildBaseString($url, ‘GET’, $oauth);
$composite_key = rawurlencode($consumer_secret) . ‘&’ . rawurlencode($oauth_access_token_secret);
$oauth_signature = base64_encode(hash_hmac(‘sha1’, $base_info, $composite_key, true));
$oauth[‘oauth_signature’] = $oauth_signature;

// Make Requests
$header = array(buildAuthorizationHeader($oauth), ‘Expect:’);
$options = array( CURLOPT_HTTPHEADER => $header,
//CURLOPT_POSTFIELDS => $postfields,
CURLOPT_HEADER => false,
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false);

$feed = curl_init();
curl_setopt_array($feed, $options);
$json = curl_exec($feed);
curl_close($feed);

$twitter_data = json_decode($json);
foreach($twitter_data as $key=>$value){
$tweet_date = date(‘Y-m-d’,strtotime($twitter_data[$key]->created_at));
$days_before = daysDifference(date(‘Y-m-d’),$tweet_date);
echo ‘


“.$days_before.” day(s) ago
admin
Articles Authored: 278