我根据文档和Linkedin新示例应用程序使用新的Linkedin Android SDK获取"访问连接被拒绝"错误: -
APIHelper apiHelper = APIHelper
.getInstance(getApplicationContext());
apiHelper.getRequest(ApiActivity.this, "https://" + host
+ "/v1/people/~/connections:(first-name,last-name,public-profile-url)",
new ApiListener() {
@Override
public void onApiSuccess(ApiResponse s) {
((TextView) findViewById(R.id.response))
.setText(s.toString());
}
@Override
public void onApiError(LIApiError error) {
((TextView) findViewById(R.id.response))
.setText(error.toString());
}
});
Run Code Online (Sandbox Code Playgroud)
同意 OAuth 用户协议: r_basicprofile 和 r_fullprofile 均未检查以获取对用户个人资料的访问权限。follow url 可用于从 LinkedIn 获取个人资料信息。
Default Scope:
r_basicprofile
r_fullprofile
Run Code Online (Sandbox Code Playgroud)
使用以下 URL 来获取 LinkedIn 数据。
private static final String HOST = "api.linkedin.com";
private static final String FETCH_BASIC_INFO = "https://" + host + "/v1/people/~:(id,first-name,last-name,headline,location,industry)";
private static final String FETCH_CONTACT = "https://" + host + "/v1/people/~:(num-connections,email-address,phone-numbers,main-address)";
private static final String FETCH_PROFILE_PIC = "https://" + host + "/v1/people/~:(picture-urls::(original))";
private static final String SHARE_URL = "https://" + host + "/v1/people/~/shares";
Run Code Online (Sandbox Code Playgroud)
不要忘记在移动 应用程序以及在 LinkedIn 中注册应用程序时设置访问上述信息的权限
private static Scope buildScope() {
return Scope.build(Scope.R_BASICPROFILE, Scope.W_SHARE, Scope.R_EMAILADDRESS, Scope.R_CONTACTINFO); }
Run Code Online (Sandbox Code Playgroud)
示例代码如下
LISessionManager.getInstance(context).init(context, buildScope(), new AuthListener() {
@Override
public void onAuthSuccess() {
}
@Override
public void onAuthError(LIAuthError error) {
}
}, true);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
893 次 |
| 最近记录: |