1

我正在使用 Android/google_play_service 库和 PlusClient 做一些工作。具体来说,我只是在 ListView 中填写了我的联系人姓名,以及他们 G+ 个人资料页面上提供的一些基本信息。

为了加载列表,我进行如下操作:

// Create my PlusClient
activityContext = getActivity().getApplicationContext();
client = new PlusClient.Builder(activityContext, this, this)
           .setScopes(Scopes.PLUS_PROFILE, Scopes.PLUS_LOGIN)
           .build();

// Load the people
//   this = the current activity
client.loadPeople(this, Person.Collection.VISIBLE);

// The below listener gets invoked when the list is loaded
... onPeopleLoaded(ConnectionResult cr, PersonBuffer pb, String nextPageToken) {
    Person contact = null;

    for (int i = 0; i < pb.getCount(); i++) {
        contact = pb.get(i);

        Log.d(TAG, contact.getDisplayName());
        Log.d(TAG, contact.getAboutMe() == null ? "Null" : contact.getAboutMe());
        Log.d(TAG, contact.getBirthday() == null ? "Null" : contact.getBirthday());
        Log.d(TAG, contact.getEmails() == null ? "Null" : contact.getEmails().toString());
        Log.d(TAG, contact.getCurrentLocation() == null ? "Null" : contact.getCurrentLocation());
        Log.d(TAG, contact.getId() == null ? "Null" : contact.getId());
        Log.d(TAG, contact.getLanguage() == null ? "Null" : contact.getLanguage());
        Log.d(TAG, contact.getUrl() == null ? "Null" : contact.getUrl());
        Log.d(TAG, contact.getName() == null ? "Null" : contact.getName().toString());
        Log.d(TAG, contact.isPlusUser() ? "true" : "false");
        Log.d(TAG, contact.isVerified() ? "true" : "false");
    }
}

在上面的代码片段中,唯一不返回 null 的方法是: - getDisplayName - getId - getUrl

...对于我所有的联系人(几百个)。我的方法 onPeopleLoaded 中收到的 PersonBuffer 中包含的 Person 对象似乎不完整。对于我的许多联系人,我在他们的 G+ 个人资料上看到的信息是可见的(他们正在与我分享)...

在旁注中,我尝试了 API 资源管理器(https://developers.google.com/+/api/latest/people/get),我仍然得到部分数据,但至少,以下两种方法似乎正在工作虽然他们不在我的 android 应用程序中: - isPlusUser - isVerified

任何解释该行为的信息将不胜感激。

4

1 回答 1

1

并非所有这些数据都可供每个用户使用。仅用户在其个人资料中设置为公开的数据或对授权对话框中明确授予的数据的访问权限。在PLUS_LOGIN您指定的范围内,您至少可以期望:基本个人资料数据(姓名、ID、照片、个人资料 URL)、年龄范围、语言和对应用程序可见的朋友列表。除此之外的任何内容都必须由用户在其 Google+ 个人资料中明确公开。

如果您需要在使用 getter 之前检查数据是否存在,还有“has”方法。有关所有配置文件方法,请参见com.google.android.gms.plus.model.people.Person

于 2013-10-01T14:49:13.873 回答