final LinkedInOAuthService oauthService = LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(consumerkeyvalue, consumerSecretValue);
LinkedInRequestToken requestToken = oauthService.getoAuthRequestToken();
我正在使用LinkedApi库,昨天这段代码正在运行,但今天我不知道为什么,但它给出了异常
LinkedInRequestToken requestToken = oauthService.getoAuthRequestToken();
它的给予:
com.google.code.linkedinapi.client.oauth.LinkedInOAuthServiceException: oauth.signpost.exception.OAuthCommunicationException: Communication with the service provider Failed: https://api.linkedin.com/uas/oauth/requestToken
解决方法:
步骤1)使用API获取引脚
oauthService= LinkedInOAuthServiceFactory.getInstance().createLinkedInOAuthService(consumerkeyvalue, consumerSecretValue);
requestToken= oauthService.getoAuthRequestToken();
//requestToken=oauthService.getoAuthRequestToken();
//getoAuthRequestToken("");
autoToken= requestToken.getToken();
authoTokenSecret = requestToken.getTokenSecret();
authUrl= requestToken.getAuthorizationUrl();
Log.i("Tok", autoToken);
Log.i("Tok", authoTokenSecret);
Log.i("Tok", authUrl);
webview.loadUrl(authUrl);
步骤2)webview将在登录后显示pin链接现在使用你的pin来获取访问令牌并使用访问令牌你可以获得配置文件和更新状态
String pin = pin_edit.getText().toString();
System.out.println("Fetching access token from LinkedIn...");
LinkedInAccesstoken accesstoken = oauthService.getoAuthAccesstoken(requestToken, pin);
System.out.println("Access token: " + accesstoken.getToken());
System.out.println("Token secret: " + accesstoken.getTokenSecret());
final LinkedInapiclientFactory factory = LinkedInapiclientFactory.newInstance(consumerkeyvalue, consumerSecretValue);
final LinkedInapiclient client = factory.createLinkedInapiclient(accesstoken);
Person profile = client.getProfileForCurrentUser();
profile.setCurrentStatus("Hello all my friends ,I am missing you all");
client.updateCurrentStatus("Hello all going");