Php 是否可以使用google帐户登录并将其信息保存到DB

Php 是否可以使用google帐户登录并将其信息保存到DB,php,google-signin,Php,Google Signin,我想知道,当用户登录到google帐户时,有没有办法将google帐户信息添加到我的数据库中,这在您使用G+api时是可能的,但在我不想使用G+api,只想集成google登录时是可能的。 你们有什么帮助吗?? 谢谢:) 函数onSignIn(谷歌用户){ //客户端脚本的有用数据: var profile=googleUser.getBasicProfile(); console.log(“ID:+profile.getId());//不要直接将其发送到服务器! log('Full Name

我想知道,当用户登录到google帐户时,有没有办法将google帐户信息添加到我的数据库中,这在您使用G+api时是可能的,但在我不想使用G+api,只想集成google登录时是可能的。 你们有什么帮助吗?? 谢谢:)


函数onSignIn(谷歌用户){
//客户端脚本的有用数据:
var profile=googleUser.getBasicProfile();
console.log(“ID:+profile.getId());//不要直接将其发送到服务器!
log('Full Name:'+profile.getName());
log('给定名称:'+profile.getGivenName());
console.log('Family Name:'+profile.getFamilyName());
log(“图像URL:+profile.getImageUrl());
log(“Email:+profile.getEmail());
//需要传递到后端的ID令牌:
var id_token=googleUser.getAuthResponse().id_token;
日志(“ID令牌:+ID_令牌”);
};


函数onSignIn(谷歌用户){
//客户端脚本的有用数据:
var profile=googleUser.getBasicProfile();
console.log(“ID:+profile.getId());//不要直接将其发送到服务器!
log('Full Name:'+profile.getName());
log('给定名称:'+profile.getGivenName());
console.log('Family Name:'+profile.getFamilyName());
log(“图像URL:+profile.getImageUrl());
log(“Email:+profile.getEmail());
//需要传递到后端的ID令牌:
var id_token=googleUser.getAuthResponse().id_token;
日志(“ID令牌:+ID_令牌”);
//您的数据在变量'id\u token'中。现在将其发送到服务器进行存储
};
您正在编写的代码是javascript。现在,您需要与服务器通信,将浏览器上的数据(驻留在javascript变量中)发送到服务器

你有不同的选择 1.将数据设置为表单并提交 2.将数据设置为查询字符串并重定向 3.通过ajax将数据发送到服务器

在服务器上,您需要使用php、java、c#等任何语言接收数据并写入数据库。


函数onSignIn(谷歌用户){
//客户端脚本的有用数据:
var profile=googleUser.getBasicProfile();
console.log(“ID:+profile.getId());//不要直接将其发送到服务器!
log('Full Name:'+profile.getName());
log('给定名称:'+profile.getGivenName());
console.log('Family Name:'+profile.getFamilyName());
log(“图像URL:+profile.getImageUrl());
log(“Email:+profile.getEmail());
//需要传递到后端的ID令牌:
var id_token=googleUser.getAuthResponse().id_token;
日志(“ID令牌:+ID_令牌”);
//您的数据在变量'id\u token'中。现在将其发送到服务器进行存储
};
您正在编写的代码是javascript。现在,您需要与服务器通信,将浏览器上的数据(驻留在javascript变量中)发送到服务器

你有不同的选择 1.将数据设置为表单并提交 2.将数据设置为查询字符串并重定向 3.通过ajax将数据发送到服务器


在服务器上,您需要使用php、java、c#等任何语言接收数据并写入数据库。

您检查了google文档,但没有什么了不起的?你认为还有什么办法可以做到这一点呢?通过谷歌文档的帮助,我可以将其集成,但我希望控制台记录的信息能够进入我的数据库。我想知道我应该在哪里做我的插入代码,这样我就可以将它添加到我的数据库中。它是可用的,但它是用于G+而不是用于google集成的。我想你已经把你需要的所有信息记录在控制台上了。现在您要将此数据保存到数据库中。我说的对吗?是的,完全正确,跟随谷歌文档的脚步,我已经做了很多。不,我需要将其存储到我的数据库中,以便用户需要在我的站点中再次注册。如果您使用javascript,则必须通过提交表单/ajax将数据发送到服务器。您查看了google文档,但没有什么了不起的事?你认为还有什么办法可以做到这一点呢?通过谷歌文档的帮助,我可以将其集成,但我希望控制台记录的信息能够进入我的数据库。我想知道我应该在哪里做我的插入代码,这样我就可以将它添加到我的数据库中。它是可用的,但它是用于G+而不是用于google集成的。我想你已经把你需要的所有信息记录在控制台上了。现在您要将此数据保存到数据库中。我说的对吗?是的,完全正确,跟随谷歌文档的脚步,我已经做了很多。不,我需要将其存储到我的数据库中,以便用户需要在我的站点中再次注册,您必须通过提交表单/ajax将数据发送到服务器。我建议您学习技术和编程语言,区分前端技术和后端/服务器技术,成为一名优秀的程序员,而不仅仅是复制粘贴。我知道每个人都是从复制开始的。我建议你学习技术和编程语言,区分前端技术和后端/服务器技术,成为一名优秀的程序员,而不仅仅是复制粘贴。我知道每个人都是从复制粘贴开始的
<div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"></div>
<script>
function onSignIn(googleUser) {
    // Useful data for your client-side scripts:
    var profile = googleUser.getBasicProfile();
    console.log("ID: " + profile.getId()); // Don't send this directly to your server!
    console.log('Full Name: ' + profile.getName());
    console.log('Given Name: ' + profile.getGivenName());
    console.log('Family Name: ' + profile.getFamilyName());
    console.log("Image URL: " + profile.getImageUrl());
    console.log("Email: " + profile.getEmail());

    // The ID token you need to pass to your backend:
    var id_token = googleUser.getAuthResponse().id_token;
    console.log("ID Token: " + id_token);
};
<div class="g-signin2" data-onsuccess="onSignIn" data-theme="dark"></div>
<script>
function onSignIn(googleUser) {
    // Useful data for your client-side scripts:
    var profile = googleUser.getBasicProfile();
    console.log("ID: " + profile.getId()); // Don't send this directly to your server!
    console.log('Full Name: ' + profile.getName());
    console.log('Given Name: ' + profile.getGivenName());
    console.log('Family Name: ' + profile.getFamilyName());
    console.log("Image URL: " + profile.getImageUrl());
    console.log("Email: " + profile.getEmail());

    // The ID token you need to pass to your backend:
    var id_token = googleUser.getAuthResponse().id_token;
    console.log("ID Token: " + id_token);
    //You have your data in the variable `id_token`. Now send this to your server to be stored
};