我做谷歌连接让用户使用他们的谷歌帐户登录.
我做的是,创建一个按钮
<div class="g-signin2 social_signin" data-onsuccess="onSignIn"></div>
Run Code Online (Sandbox Code Playgroud)
然后创建onSignIn()
<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("Name: " + profile.getName());
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);
};
</script>
Run Code Online (Sandbox Code Playgroud)
然后将该令牌发送到PHP服务器以进行验证并获取数据.这很好.
但我的问题是,当用户从我的网站注销时,谷歌会自动触发'onSignIn'而不点击我创建的按钮.因此,当用户注销时,用户会自动再次登录.
你能帮助我防止这种自动登录吗?或者我可以取消授权用户吗?
我的字符串就像https://www.facebook.com/connect/login_success.html?request=516359075128086&to%5B0%5D=100004408050639&to%5B1%5D=1516147434&_=_
此字符串是发送到 Facebook 的应用程序邀请 URL 重定向请求的结果。
我想要做的是将用户 id 100004408050639 和 1516147434 提取到一个数组中。
我尝试过var fbCode = testString.match(/to%5B0%5D=(.*)&/);
,但这仅返回这些数字中的一个,即第一次出现。