gpt4 book ai didi

java - 如何在 Android 中获取 LinkedIn 联系人或好友列表?

转载 作者:行者123 更新时间:2023-11-30 03:16:32 25 4
gpt4 key购买 nike

任何人都可以使用 LinkedIn API linkedin-j-android.jar 帮助我获取 LinkedIn 联系人或 friend 或连接列表。我能够获取所有当前用户个人资料信息,但不知道如何获取联系人或 friend 列表.我在 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 合作伙伴的权限。您可以在这里申请访问他们的合作伙伴计划:

https://developer.linkedin.com/partner-programs/apply

关于java - 如何在 Android 中获取 LinkedIn 联系人或好友列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19993634/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com