I am trying to display my Twitter feeds using Twitter API 1.1. I have been searching for this but didn't get a proper solution.I have tried this using Abraham/TwitterOAuth library and it works fine. But my new task is not to use any 3rd party libraries.
Here I tried using cURL,
<?php
$options = array(
CURLOPT_HTTPHEADER => array('Authorization: OAuth oauth_consumer_key="aaaaaaa", oauth_nonce="bbbbbbb", oauth_signature="cccccc%ddddddd%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1426752199", oauth_token="eeeeeeeee-fffffffffffff", oauth_version="1.0"'),
CURLOPT_HEADER => false,
CURLOPT_URL => 'https://api.twitter.com/1.1/statuses/user_timeline.json?count=2&screen_name=myscreen_name',
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYPEER => false
);
$feed = curl_init();
curl_setopt_array($feed, $options);
$json = curl_exec($feed);
curl_close($feed);
$twitter_data = json_decode($json);
var_dump($twitter_data);
?>
and it returns with an error
object(stdClass)#1 (1) {
["errors"]=>
array(1) {
[0]=>
object(stdClass)#2 (2) {
["code"]=>
int(215)
string(24) "Could not authenticate you"
}
}
}
I am not getting where I am going wrong. How to make it work?