0

I am having a Twitter API , I checked it's output from the Twitter console where it authenticates with OAuth , there I get correct JSON response . I want to implement in my code in Java .

I have all 4 information consumer key , secret , access token , access secret .

https://api.twitter.com/1.1/statuses/user_timeline.json?count=3&user_id='id'&screen_name='name'

I want to get JSON response from this API and using OAuth client .

I tried few way of setting up OAuth client for getting json response using these documentations but it didn't work . http://www.smartjava.org/content/access-twitter-rest-api-v11-scala-and-java-using-signpost

Can anyone please share code snippet/ relevant doc of OAuth client for Twitter API 1.1 , that will be very helpful .

Regards

user3837000
  • 121
  • 3
  • 12
  • Any reason you don't just use http://twitter4j.org/en/code-examples.html – Yuri Schimke Oct 31 '16 at 19:24
  • It has not merged it's code of taking in account tweet_mode=extended and we are not able to see the image in JSON response . Hence we need to do new implementation and remove twitter 4j – user3837000 Nov 01 '16 at 08:47
  • It seems like getting the PR working and using a dev build of twitter4j is simpler. But here are some examples using OkHttp for the auth flow and signing https://github.com/yschimke/oksocial/blob/master/src/main/java/com/baulsupp/oksocial/services/twitter/TwitterAuthFlow.java https://github.com/yschimke/oksocial/blob/master/src/main/java/com/baulsupp/oksocial/services/twitter/Signature.java – Yuri Schimke Nov 01 '16 at 10:33
  • Thanks Yuri , we could had used PR code . But in our project Twitter 4j is used as maven dependency and we can't make changed in compiled classes . Hence if the PR had merged to master , then only it will have served our purpose – user3837000 Nov 01 '16 at 11:39
  • Also Yuri in above classes what value of TwitterCredentials unauthed, String callback , String verifier we have to pass to make it working – user3837000 Nov 01 '16 at 11:42
  • You can checkout https://stackoverflow.com/a/59765764/1776132 for pure Java solution without any library. – Smile Jan 31 '20 at 16:50

0 Answers0