2015-05-14 42 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