As said before, I have written a java program using scribe library to post status message on my Twitter Timeline.
Sample code:
String URL_POST_TWEET = "https://api.twitter.com/1.1/statuses/update.json";
try{
OAuthRequest request = new OAuthRequest(Verb.POST, URL_POST_TWEET);
request.setCharset("UTF-8");
request.addBodyParameter("status","Some tweet");
twitter.signRequest(USER_TOKEN, request);
Response response = request.send();
System.out.println("Response:" +response.getBody());
}
catch(Exception e) {
e.printStackTrace();
}
When I had executed the above code in eclipse, I got the following response in the console:
root flush - signing request: https://api.twitter.com/1.1/statuses/update.json
root flush - setting token to: Token[********-***********]
root flush - generating signature...
root flush - using base64 encoder: DatatypeConverter
root flush - base string is: POST&https%3A%2F%2Fapi.twitter.com%2F1.1%2Fstatuses%2Fupdate.json&oauth_consumer_key%3DA6zV8RC70fdDFIDzfFIpmA%26oauth_nonce%3D2847951734%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1478500810%26oauth_token%3D15656849-zp74Iyx3N6vhWE1FSunVEJVhPbmcZqFNWf1rV4nht%26oauth_version%3D1.0%26status%3D%2522People%2520laughed%2520at%2520this%2520AI%2520accelerator%2520for%2520Asia%2520This%2520is%2520its%2520killer%2520first%2520lineup%2522%2520https%253A%252F%252Fgoo.gl%252FFzWkk3
root flush - signature is: HxzfOd38R3lBQ2fVoIJKiYiZgY8=
root flush - appended additional OAuth parameters: { oauth_nonce -> 2847951734 , oauth_signature -> HxzfOd38R3lBQ2fVoIJKiYiZgY8= , oauth_token -> 15656849-zp74Iyx3N6vhWE1FSunVEJVhPbmcZqFNWf1rV4nht , oauth_consumer_key -> A6zV8RC70fdDFIDzfFIpmA , oauth_timestamp -> 1478500810 , oauth_signature_method -> HMAC-SHA1 , oauth_version -> 1.0 }
root flush - using Http Header signature
After printing these lines, process didn’t moved further and got stuck, without terminating.
I guess it has stuck at this line.
twitter.signRequest(USER_TOKEN, request);
What may be the reason for this issue. Can we handle these kind of issues. If yes? then please reply me with a solution.
Thanks