0
如何在通過Google API登錄某人時檢查用戶是否具有默認圖像(例如,image.isDefault
結果)。我使用getBasicProfile()檢索id
,name
,email
,imageUrl
...等Google API Javascript登錄 - 檢查用戶圖像是否爲默認
<html>
<head>
<script src="https://apis.google.com/js/api:client.js"></script>
<script>
var googleUser = {};
var startApp = function() {
gapi.load('auth2', function(){
auth2 = gapi.auth2.init({
client_id: 'YOUR_CLIENT_ID.apps.googleusercontent.com',
cookiepolicy: 'single_host_origin',
// Request scopes in addition to 'profile' and 'email'
//scope: 'additional_scope'
});
attachSignin(document.getElementById('customBtn'));
});
};
function attachSignin(element) {
console.log(element.id);
auth2.attachClickHandler(element, {},
function(googleUser) {
var profile = googleUser.getBasicProfile();
var response = {};
response.id = profile.getId();
response.name = profile.getName();
response.first_name = profile.getGivenName();
response.last_name = profile.getFamilyName();
response.image_url = profile.getImageUrl();
response.email = profile.getEmail();
console.log(response);
//******* HOW TO GET THE "image.isDefault" RESULT? ******
}, function(error) {
alert(JSON.stringify(error, undefined, 2));
});
}
</script>
</head>
<body>
<div id="gSignInWrapper">
<span class="label">Sign in with:</span>
<div id="customBtn" class="customGPlusSignIn">
<span class="icon"></span>
<span class="buttonText">Google</span>
</div>
</div>
<div id="name"></div>
<script>startApp();</script>
</body>
</html>
這是我在尋找對象:
ageRange: Object
min: 21
circledByCount: 0
displayName: "John Smith"
etag: ""FT7asdjf83294289sf/sh-UjzBIkCHasfdj283429sf""
id: "1127384729842983928"
image:
isDefault: true
url: "https://lh3.googleusercontent.com/-XYuefSD/AAAAAAAAAAI/AAAAAAAAAAA/23visd238/photo.jpg?sz=50"
isPlusUser: true
kind: "plus#person"
language: "en"
name:
familyName: "Smith"
givenName: "John"
objectType: "person"
url: "https://plus.google.com/118948298492849237"
verified: false
它只是重新打開默認圖像 – Viney