未捕获的TypeError:undefined不是Google Plus登录的功能

时间:2014-10-27 13:23:18

标签: javascript jquery google-plus

我正在尝试实施Google plus登录及其代码

$('#GPlogin').on('click', function () {

  var myParams = {
    'clientid' : 'My ID.apps.googleusercontent.com',
    'cookiepolicy' : 'single_host_origin',
    'callback' : 'GPlogin',
    'approvalprompt':'force',
    'scope' : 'https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.profile.emails.read'
  };
  gapi.auth.signIn(myParams);

}); 


function GPlogin(result)
{
    console.log(result);
    if(result['status']['signed_in'])
    {
        var request = gapi.client.plus.people.get(
        {
            'userId': 'me'
        });
        request.execute(function (resp)
        {
            var email = '';
            if(resp['emails'])
            {
                for(i = 0; i < resp['emails'].length; i++)
                {
                    if(resp['emails'][i]['type'] == 'account')
                    {
                        email = resp['emails'][i]['value'];
                    }
                }
            }

            var str = "Name:" + resp['displayName'] + "<br>";
            str += "Image:" + resp['image']['url'] + "<br>";
            str += "<img src='" + resp['image']['url'] + "' /><br>";

            str += "URL:" + resp['url'] + "<br>";
            str += "Email:" + email + "<br>";
            console.log(str);
        });

    }

}


function onLoadCallback()
{
    //gapi.client.setApiKey('My API Key'); //set your API KEY
    gapi.client.load('plus', 'v1',function(){});//Load Google + API
}



(function() {
  var po = document.createElement('script');
  po.type = 'text/javascript'; po.async = true;
  po.src = 'https://plus.google.com/js/client:plusone.js?onload=loadGApi';
  var s = document.getElementsByTagName('script')[0];
  s.parentNode.insertBefore(po, s);
})();

第一次模态窗口询问我的权限,然后在控制台中我收到错误

  

未捕获的TypeError:undefined不是函数

当我按下登录按钮模式后询问我的离线使用权限并在控制台中收到同样的错误

0 个答案:

没有答案
相关问题