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/updat e.xml</req uest>
<error>Could not authenticate you.</error>
</hash>"
http request is:
"HTTP request => POST /1/statuses/update.xml
Content-Type: application/x-www-form-url encoded
User-Agent: Jakarta Commons-HttpClient/3.1
Host: api.twitter.com
Content-Length: 277
status=testing%20Twitter%2 1&oauth_to ken=sWtx2n mAyBaFLzh5 WbR6gGRHV9 KjF7TFnioJ Ct87ubs&oa uth_consum er_key=Xc8 W0rJuwkLPd fTngewBg&o auth_signa ture_metho d=HMAC-SHA 1&oauth_ti mestamp=12 71968710&o auth_nonce =162012765 462908&oau th_version =1.0&oauth _signature =KrLsQjVHU KoZHVPgAaK CqSXLdDI%3 D"
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=12719687132116721 5; path=/; expires=Sat, 22 May 2010 20:38:33 GMT
Set-Cookie: _twitter_sess=BAh7CDoPY3Jl YXRlZF9hdG wrCPxJPico AToHaWQiJT g1ZjE0YzNm YjMyZjFm%2 50AZjM3MTd mNDM3MTAxN GEyODI5Igp mbGFzaElDO idBY3Rpb25 Db250cm9sb GVy%250AOj pGbGFzaDo6 Rmxhc2hIYX NoewAGOgpA dXNlZHsA-- 4b722ac7a4 38e73c7579 47649e1d18 9f1fc9f29a ; 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/updat e.xml</req uest>
<error>Could not authenticate you.</error>
</hash>
"
"<?xml version => "1.0" encoding="UTF-8"?>
<hash>
<request>/1/statuses/updat
<error>Could not authenticate you.</error>
</hash>"
http request is:
"HTTP request => POST /1/statuses/update.xml
Content-Type: application/x-www-form-url
User-Agent: Jakarta Commons-HttpClient/3.1
Host: api.twitter.com
Content-Length: 277
status=testing%20Twitter%2
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=12719687132116721
Set-Cookie: _twitter_sess=BAh7CDoPY3Jl
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/updat
<error>Could not authenticate you.</error>
</hash>
"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:)
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