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