问题
This does NOT happen when I use it with a GET.
i.e.
this DOES NOT WORK:
ProxyAuthenticator pa = new ProxyAuthenticator();
Authenticator.setDefault( pa );
OAuthService service = new ServiceBuilder().provider( TwitterApi.class ).apiKey( strAPIKey ).apiSecret( strAPISecret ).build();
Token requestToken = service.getRequestToken();
Scanner in = new Scanner( System.in );
Verifier verifier = new Verifier(in.nextLine());
String url = "http://api.twitter.com/1/statuses/update.json?status=helllllooooo";
OAuthRequest request = new OAuthRequest( Verb.POST, url );
service.signRequest( accessToken , request2 );
final Response response = request.send();
Response returns a 401. However, using a GET with the above code returns a 200 in response. i.e.
url = "http://api.twitter.com/1/account/verify_credentials.json";
OAuthRequest request = new OAuthRequest( Verb.GET, url );
service.signRequest( accessToken, request );
Response resp = request.send();
Any ideas what I should do?
回答1:
I know this is asked about in a different language, but some of the principles are the same. and one of the answers mentions solving this in java.
Getting 401 on Twitter OAuth POST requests
来源:https://stackoverflow.com/questions/7001629/401-response-when-do-a-post-using-scribe-oauth-java