2015-05-14 46 views
5

我正在用新的LinkedIn的Android SDK按文档和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

我也具有与iOS API相同的问题。 –

回答

2

同意的OAuth用户协议: 无论是r_basicprofile还是r_fullprofile都没有检查用户配置文件的访问权限。以下url可用于从LinkedIn获取配置文件 信息。

Default Scope: 
    r_basicprofile 
    r_fullprofile 

用户以下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"; 

不要忘记设置权限在两个移动 应用使用上述信息,以及而在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); 
+0

private static final String FETCH_CONTACT =“https://”+ host +“/ v1/people /〜:(num-connections,email-address,phone-numbers,main-address)”; 提供了不是联系人的连接数。 –

+0

是的,它没有说它会取得连接。我要求他检查权限。 :) –

+0

那么,我们有什么想法可以读取用户连接(例如名称,ID,图片URL)吗?我已经通过新的LinkedIn API,我无法弄清楚我需要拥有哪些权限(https://developer.linkedin.com/docs)。我知道“r_network”作用域参数已被弃用,并且应用程序也需要先被验证。但是,在“使用LinkedIn申请”,“在LinkedIn上共享”,“管理公司页面”,“向证书添加证书”中,我们是否必须申请访问用户的连接? – Dimitris