Hello,
I’m creating an API for my Twitter app and i’m using Twitter’s OAuth Echo.
Here’s my code:
$header_info = apache_request_headers();
$header = 'Authorization : ' . $header_info['X-Verify-Credentials-Authorization'];
Here’s how the $header_info[‘X-Verify-Credentials-Authorization’] looks like (i’ve just replace actual values with XXXXXX):
OAuth realm=“http://api.twitter.com/”, oauth_consumer_key=“XXXXXX”, oauth_signature_method=“HMAC-SHA1”, oauth_token=“XXXXXX”, oauth_timestamp=“1329026580”, oauth_nonce=“1329026580”, oauth_version=“1.0”, oauth_signature=“XXXXXX”
Code to pass the header to Twitter:
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, "myAgent");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_URL,$header_info['X-Auth-Service-Provider']);
$result = curl_exec($ch);
$response_info=curl_getinfo($ch);
curl_close($ch);
I’m always getting a 401 error. Any help would be greatly appreciated.
Thanks,
Krishley