Hello all, can anybody help me with TwitPic please? Just cannot figure out what am I doing wrong :(
I'm trying to upload a pic making POST request to http://api.twitpic.com/2/upload.json To do this I create required header mocking GET and signing it: HttpGet oauth_get = new HttpGet("https://api.twitter.com/1/account/ verify_credentials.json"); signer.signRequest(oauth_get); (using Commons httpclient 4.1 and signpost) Then I cut out and modify header as required by TwitPic: String get_value = oauth_get.getFirstHeader("Authorization").getValue(); get_value = get_value.replaceFirst("OAuth ","OAuth realm= \"http://api.twitter.com/\", "); Then I create actual POST request, add required headers and paramenets (key,message, file): HttpPost method = new HttpPost("http://api.twitpic.com/2/ upload.json"); method.setHeader("X-Verify-Credentials- Authorization",get_value); method.setHeader("X-Auth-Service-Provider","https:// api.twitter.com/1/account/verify_credentials.json"); MultipartEntity entity; FileBody media = new FileBody(pic,"image/png"); entity = new MultipartEntity(null,null,Charset.forName("UTF-8")); entity.addPart("media",media); try { for(NameValuePair pair:params) { entity.addPart(pair.getName(),new StringBody(pair.getValue(),Charset.forName("UTF-8"))); } method.setEntity(entity); } catch(UnsupportedEncodingException e) { logger.log(Level.WARNING, e.toString()); } return method; And then I send the request (method). Here is what I receive: WARNING: Authentication error: Unable to respond to any of these challenges: {} and right after 401 error code. It is important that direct call to Twitter for verification: HttpGet method = new HttpGet("https://api.twitter.com/1/account/ verify_credentials.json"); signer.signRequest(method); return method; returns OK what means all authentification parameters correct. So, it is the header for TwitPic. Can anybody point out what's wrong with how am I creating it? Thank you. -- Twitter developer documentation and resources: http://dev.twitter.com/doc API updates via Twitter: http://twitter.com/twitterapi Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list Change your membership to this group: http://groups.google.com/group/twitter-development-talk