访问连接被拒绝新的Android SDK

时间:2015-05-14 12:35:06

标签: android linkedin

我正在获得"访问被拒绝的连接"根据文档和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());
                                }
                            });

1 个答案:

答案 0 :(得分:2)

  

同意OAuth用户协议:    检查r_basicprofile和r_fullprofile是否都无法访问用户个人资料。以下网址可用于获取个人资料   来自LinkedIn的信息。

Default Scope:
    r_basicprofile
    r_fullprofile   
  

使用以下网址获取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";
  

请勿忘记设置在移动设备上访问以上信息的权限    应用以及在LinkedIn中注册应用

 private static Scope buildScope() {
 return Scope.build(Scope.R_BASICPROFILE, Scope.W_SHARE, Scope.R_EMAILADDRESS, Scope.R_CONTACTINFO); }
  

示例代码如下

LISessionManager.getInstance(context).init(context, buildScope(), new AuthListener() {
                @Override
                public void onAuthSuccess() {

                }

                @Override
                public void onAuthError(LIAuthError error) {

                }
            }, true);