我在google plus文档中看到users have cover photos.
所以这里有一个关于如何使用我认为足够的权限构建api客户端以及获取当前人物封面照片以及其他信息的要点。
private static final String SCOPE_EMAIL =
"https://www.googleapis.com/auth/plus.profile.emails.read";
private GoogleApiClient buildGoogleApiClient() {
return new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API, Plus.PlusOptions.builder().build())
.addScope(Plus.SCOPE_PLUS_LOGIN)
.addScope(new Scope(SCOPE_EMAIL))
.addScope(Plus.SCOPE_PLUS_PROFILE).build();
}
private User createUserFromGoogle() {
_googleApiClient = buildGoogleApiClient();
Person currentUser = Plus.PeopleApi.getCurrentPerson(_googleApiClient);
String userUID = GOOGLE_UID_PREFIX + currentUser.getId();
String firstName = currentUser.getName().getGivenName();
String lastName = currentUser.getName().getFamilyName();
String email = Plus.AccountApi.getAccountName(_googleApiClient);
String profileURL = getLargeImageURL(currentUser);
Person.Cover cover = currentUser.getCover();
String coverURL = null;
Timber.e("has cover:" + currentUser.hasCover());
if (cover != null) {
CoverPhoto coverPhoto = cover.getCoverPhoto();
if (coverPhoto != null) {
coverURL = coverPhoto.getUrl();
}
}
//Create a new {@link User} with empty groups, contacts, and channels
Id id = Id.builder().value(userUID).build();
return User.create(id, firstName, lastName, email, profileURL, coverURL, null, null, null);
}
createUserFromGoogle()
在使用google plus登录进行身份验证后调用,当我们连接时#34;在ConnectionCallbacks
。每次hasCover()
始终返回false,Cover
始终为null。有没有人成功下载过coverPhoto网址?所有其他信息都已成功检索。