I am trying to use Twitter API for tweeting using an access token. When i am using the API for posting a status like "Hey guys", it succeeds and i can see the tweet on my timeline, but when i post "Hey guys :)" i get the following response:
{errors=[{code=32, message=Could not authenticate you.}]}
Here is the request that succeeds (sending "hey guys"):
client.target("https://api.twitter.com/1.1/statuses/update.json")
.queryParam("status", "hey%20guys")
.request()
.post(javax.ws.rs.client.Entity.text("sdfsdf"))
.readEntity(Object.class);
Here is the request that fails (sending "hey guys :)" ):
client.target("https://api.twitter.com/1.1/statuses/update.json")
.queryParam("status", "hey%20guys%20%3A)")
.request()
.post(javax.ws.rs.client.Entity.text("sdfsdf"))
.readEntity(Object.class);
For encoding the text I used http://meyerweb.com/eric/tools/dencoder/
For sending requests using the API i use javax.ws.rs.client.Client.
I have also tried to find any reference in Twitter API documentation for this issue but didn't find anything related. Their API contains an example for posting but i can post that one as well.
If you encode the parenthesis, that will fix it.
status = status.replaceAll("\\(","%28").replaceAll("\\)","%29");
client.target("https://api.twitter.com/1.1/statuses/update.json")
.queryParam("status", status)
.request()
...