Update status with api is failed


#1

when I try to update status with Rest API v1.1, it always result error message like this :
HTTP/1.1 100 Continue

HTTP/1.1 400 Bad Request
content-length: 61
content-type: application/json; charset=utf-8
date: Sun, 21 Apr 2013 06:03:39 UTC
server: tfe
set-cookie: guest_id=v1%3A136652421928549286; Domain=.twitter.com; Pa
strict-transport-security: max-age=631138519

{“errors”:[{“message”:“Bad Authentication data”,“code”:215}]}

here my code :
<?php
echo tweet(“hello world !!”);
function tweet($str){
$data = array(‘status’ => urlencode($str));
$header = array(
‘Authorization: OAuth oauth_consumer_key=“3UB9K2sS*******”’,
‘oauth_nonce=“9308b1*****************”’,
‘oauth_signature=“A30NmXdvM%2F0*******”’,
‘oauth_signature_method=“HMAC-SHA1”’,
‘oauth_timestamp="****523799"’,
‘oauth_token="**5009-BtvXPHj6luIqfMH"’,
‘oauth_version=“1.0”’
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “https://api.twitter.com/1.1/statuses/update.json”);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, “Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0)”);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$exec = curl_exec($ch);
curl_close($ch);
return $exec;
}
?>

what the problem ?


#2

please help me…


#3

API v1.1 is stricter about valid HTTP 1.1 and OAuth 1.0A. Take a look at the encoding you’re doing for your status – your example has two exclamation marks as well as space characters – they all need to be properly escaped both before being prepared for the POST body as well as before being sent through the OAuth signature base string.


#4

means, my code is correct, just wrong in encode of status ?


#5

After authorizing properly using oAuth with Key/Secret I try to update status and is not working. I am using TwitterAPI for .Net. Stopped working on June 11.

    Dim twitter As New TwitterConnect()
    twitter.Tweet("hello")

#6

also i tried with the examples from the libraries you recommend linq2twitter