相关疑难解决方法(0)

通过 Javascript 和 PHP 登录 Google+

你能告诉我,我如何通过 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)

php google-login google-plus google-oauth

1
推荐指数
1
解决办法
3391
查看次数

标签 统计

google-login ×1

google-oauth ×1

google-plus ×1

php ×1