2012-06-07 76 views

回答

9

如果用戶的電子郵件地址專門授權您的應用程序查看其電子郵件地址,您可以檢索該用戶的電子郵件地址。

設置你的範圍來:

https://www.googleapis.com/auth/plus.login 
https://www.googleapis.com/auth/userinfo.email 

中的JavaScript調用看起來是這樣的:

gapi.client.load('oauth2', 'v2', function() { 
    gapi.client.oauth2.userinfo.get().execute(function(resp) { 
    // Shows user email 
    console.log(resp.email); 
    }) 
}); 

gapi.client.load('plus', 'v1', function() { 
    gapi.client.plus.people.get({'userId' : 'me'}).execute(function(resp) { 
    // Shows other profile information 
    console.log(resp); 
    }) 
}); 

更多信息https://developers.google.com/+

請注意,您不需要plus.me或userinfo.profile的作用域。

+1

謝謝你cartland – srp

+0

謝謝你cartland ......... :) –

1

暴露未將其設置爲「公開」可見的人的電子郵件地址顯然是隱私問題,所以這是不可能的。

公開已將電子郵件地址可見性設置爲「公開」的人的電子郵件地址是可能的,但還沒有。它目前是open issue

編輯:現在問題已解決,因此您可以按照其他答案中的步驟來獲取它。

+0

謝謝您的回覆。 – srp

相關問題