Hello,
I’m trying to update a user’s status in php using the following code but each time i am getting a 401 error
$twitter_url = 'https://api.twitter.com/1/statuses/update.json';
$tweet = "test tweet";
$post_parameters="oauth_consumer_key=".$request->get_parameter('oauth_consumer_key')."&oauth_signature_method=".$request->get_parameter('oauth_signature_method').
"&oauth_token=".$request->get_parameter('oauth_token')."&oauth_timestamp=".$request->get_parameter('oauth_timestamp')."&oauth_nonce=".$request->get_parameter('oauth_nonce').
"&oauth_version=".$request->get_parameter('oauth_version')."&oauth_signature=".urlencode($request->get_parameter('oauth_signature'))."&status=".urlencode($tweet);
$ci = curl_init();
curl_setopt($ci, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ci, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ci, CURLOPT_TIMEOUT, 10);
curl_setopt($ci, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ci, CURLOPT_HEADER, FALSE);
curl_setopt($ci, CURLINFO_HEADER_OUT, TRUE);
curl_setopt($ci, CURLOPT_VERBOSE, true);
curl_setopt($ci, CURLOPT_POST, TRUE);
curl_setopt($ci, CURLOPT_POSTFIELDS, $post_parameters);
curl_setopt($ci, CURLOPT_URL, $twitter_url);
$result = curl_exec($ci);
$response_info=curl_getinfo($ci);
curl_close ($ci);
return $response_info;
I am 100% sure that all the parameters set in $post_parameters are correct because when i use them for verifying credentials, i receive an HTTP 200 header. The problem is in my opinion coming from the curl section.
Can someone please help?
Thanks,
Krishley