[英]Access to connections denied new 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());
}
});
同意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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.