Link to home
Start Free TrialLog in
Avatar of cgray1223
cgray1223

asked on

posting twitter updates using oauth and java question

I'm trying to post to the twitter update status api using oauth and I'm getting a 401 without any other error information.  I'm posting to http://api.twitter.com/1/statuses/update.xml with a parameter of status="testing twitter!" and a access token and access secret generated by twitter/oauth.  I've tried generating new tokens both for the twitter application and the twitter user account.  I feel everything is valid, any ideas?

"<?xml version => "1.0" encoding="UTF-8"?>
<hash>
  <request>/1/statuses/update.xml</request>
  <error>Could not authenticate you.</error>
</hash>"

http request is:
"HTTP request => POST /1/statuses/update.xml
Content-Type: application/x-www-form-urlencoded
User-Agent: Jakarta Commons-HttpClient/3.1
Host: api.twitter.com
Content-Length: 277

status=testing%20Twitter%21&oauth_token=sWtx2nmAyBaFLzh5WbR6gGRHV9KjF7TFnioJCt87ubs&oauth_consumer_key=Xc8W0rJuwkLPdfTngewBg&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1271968710&oauth_nonce=162012765462908&oauth_version=1.0&oauth_signature=KrLsQjVHUKoZHVPgAaKCqSXLdDI%3D"

response is:
"HTTP response => HTTP/1.1 401 Unauthorized
Date: Thu, 22 Apr 2010 20:38:33 GMT
Server: hi
Status: 401 Unauthorized
WWW-Authenticate: Basic realm="Twitter API"
X-Runtime: 0.00163
Content-Type: application/xml; charset=utf-8
Content-Length: 143
Cache-Control: no-cache, max-age=1800
Set-Cookie: guest_id=127196871321167215; path=/; expires=Sat, 22 May 2010 20:38:33 GMT
Set-Cookie: _twitter_sess=BAh7CDoPY3JlYXRlZF9hdGwrCPxJPicoAToHaWQiJTg1ZjE0YzNmYjMyZjFm%250AZjM3MTdmNDM3MTAxNGEyODI5IgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVy%250AOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA--4b722ac7a438e73c757947649e1d189f1fc9f29a; domain=.twitter.com; path=/
Expires: Thu, 22 Apr 2010 21:08:33 GMT
Vary: Accept-Encoding
Connection: close

<?xml version="1.0" encoding="UTF-8"?>
<hash>
  <request>/1/statuses/update.xml</request>
  <error>Could not authenticate you.</error>
</hash>
"
Avatar of mukundha_expert
mukundha_expert

strangely the HTTP reponse header has WWW-Authenticate: Basic realm="Twitter API",
maybe that the Twitter API asks you to Authenticate again or maybe your consumer key is wrong - i am noy sure.

to check this you may try to do a GET request using OAuth in a browser, the redirects are handled by the browser so it will be easier for your to check
ASKER CERTIFIED SOLUTION
Avatar of cgray1223
cgray1223

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial