scribe + twitter > Cannot get String from a null object

我是研究僧i 提交于 2019-12-06 14:27:52

Fortunately, Scribe has SSL support, you just need to use the correct TwitterAPI class inside the builder (the one intended for SSL connections:

final OAuthService service = new ServiceBuilder()
.provider(**TwitterApi.SSL.class**)
.apiKey(...)
.apiSecret(...)
.callback(...)
.build();

Worked for me like a charm :)

I had encountered this problem too...

What I did was I created a custom TwitterApi like bellow. For some reason, twitter oauth stopped supporting http and only supports ssl. see below.

import org.scribe.builder.api.DefaultApi10a;
import org.scribe.model.Token;


public class CustomTwitterApi extends DefaultApi10a {

private static final String AUTHORIZATION_URL = "https://api.twitter.com/oauth/authorize?oauth_token=%s";

public String getRequestTokenEndpoint() {
    return "https://api.twitter.com/oauth/request_token";
}

public String getAccessTokenEndpoint() {
    return "https://api.twitter.com/oauth/access_token";
}

public String getAuthorizationUrl(Token requestToken) {
    return String.format(AUTHORIZATION_URL, requestToken.getToken());
}
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!