[英]How to get LinkedIn Contacts or Friends List in Android?
有誰能幫助我使用LinkedIn APIlinkedin-j-android.jar獲取LinkedIn聯系人或朋友列表或連接列表。我能夠獲取所有當前用戶資料信息,但不知道如何獲取聯系人列表或朋友列表。在SO和Google上都找到了很多,但仍然沒有合適的解決方案。請有人幫我解決這個問題。為此,我已經嘗試過了。
ProgressDialog progressDialog = new ProgressDialog(this);
LinkedinDialog d = new LinkedinDialog(this, progressDialog);
d.show();
// set call back listener to get oauth_verifier value
d.setVerifierListener(new OnVerifyListener() {
@Override
public void onVerify(String verifier) {
try {
accessToken = LinkedinDialog.oAuthService
.getOAuthAccessToken(LinkedinDialog.liToken,
verifier);
LinkedinDialog.factory.createLinkedInApiClient(accessToken);
client = factory.createLinkedInApiClient(accessToken);
// client.postNetworkUpdate("Testing by Mukesh!!! LinkedIn wall post from Android app");
Loggger.i(TAG, "ln_access_token: " + accessToken.getToken());
Loggger.i(TAG,
"ln_access_token: " + accessToken.getTokenSecret());
com.google.code.linkedinapi.schema.Person profile = client
.getProfileForCurrentUser(EnumSet.of(
ProfileField.ID, ProfileField.FIRST_NAME,
ProfileField.LAST_NAME,
ProfileField.CONNECTIONS));
linkedInID = profile.getId();
Loggger.i(TAG, "PersonID : " + linkedInID);
linkedInFirstName = profile.getFirstName();
linkedInLastName = profile.getLastName();
Connections = profile.getConnections();
Log.e(TAG, "CONNECTION : " + Connections);
List<Contact> contactList;
contactList = (ArrayList<Contact>) getIntent()
.getSerializableExtra("contact");
for (int i = 0; i < contactList.size(); i++) {
final Contact bean = contactList.get(i);
Log.d("Custom-UI",
"Display Name = " + bean.getDisplayName());
Log.d("Custom-UI",
"First Name = " + bean.getFirstName());
Log.d("Custom-UI", "Last Name = " + bean.getLastName());
Log.d("Custom-UI", "Contact ID = " + bean.getId());
Log.d("Custom-UI",
"Profile URL = " + bean.getProfileUrl());
Log.d("Custom-UI",
"Profile Image URL = "
+ bean.getProfileImageURL());
Log.d("Custom-UI", "Email = " + bean.getEmail());
}
Loggger.e(TAG, "connections : " + Connections);
Loggger.e(TAG, "linkedin firstname : " + linkedInFirstName);
Loggger.e(TAG, "linkedin lastname : " + linkedInLastName);
} catch (Exception e) {
e.printStackTrace();
}
}
});
// set progress dialog
progressDialog.setMessage("Loading...");
progressDialog.setCancelable(true);
progressDialog.show();
r_network范圍最近已更改為僅限LinkedIn合作伙伴的權限。 您可以在此處申請訪問其合作伙伴計划的權限:
1,請參考此鏈接: https : //github.com/Hafiz-Waleed-Hussain/EasyLinkedInAndroid作為庫
2,在主Java布局中使用:
_EasyLinkedIn = EasyLinkedIn.getInstance(this, "api key",
"secret key",
"https://github.com/Hafiz-Waleed-Hussain/EasyLinkedInAndroid",
"", "");
_EasyLinkedIn.authorize(MainActivity.this, new Callback() {
@Override
public void onSucess(Object data) {
String fields = "id,first-name,headline";
_EasyLinkedIn.getUserInfo(this, this, fields);
String fields1 = "id";
String url = "https://api.linkedin.com/v1/people/~/connections:(id=Gcn6gB9aCj)?format=json&oauth2_access_token="
+ EasyLinkedIn.getAccessToken();
_EasyLinkedIn.getConnections(this, this, fields1);
}
@Override
public void onFailure() {
}
});
onDownloadingComplete()方法使用日志來打印對象參數
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.