你能告诉我,我如何通过 Google+ Javascript/Php api 获取用户数据(姓名、电子邮件)?我按照这个教程去,它描述了如何authResult['code']通过 Javascript获取。
没关系,我有。我通过 Ajax 将它发送到服务器,但我不知道如何通过 PHP BUT 获取用户数据,如姓名和电子邮件,而无需任何重定向。以下是 Javascript 代码示例:
function googleStart()
{
console.log('googleStart');
gapi.load('auth2', function()
{
auth2 = gapi.auth2.init({
client_id: '811214467813-v3fmui5dfghte5m0kmohsf6dl11ori3tg.apps.googleusercontent.com',
// Scopes to request in addition to 'profile' and 'email'
fetch_basic_profile: false,
scope: 'profile email'
});
});
}
function googleSignIn(authResult)
{
console.log(authResult);
if (authResult['code']) {
console.log(authResult);
// Hide the sign-in button now that the user is authorized, for example:
$('#signinButton').attr('style', 'display: none');
// Send the code to the server
$.ajax({ …Run Code Online (Sandbox Code Playgroud)