我正在尝试通过facebook登录我的用户。我不太确定在此代码中没有做什么。数据库中没有输入任何内容。来自页面fb_action.php
使用facebook按钮登录时,除了发送到fb_action.php的数据外,所有成功
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId : 'APP_ID', // replace your app id here
channelUrl : 'channel.html',
status : true,
cookie : true,
xfbml : true
});
};
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
/*** USER TRIGGERED JS ***/
var username = '';
var userid = '';
var userEmail = '';
var userMac = '$(mac)';
function FBLogin(){
FB.login(function(response){
if(response.authResponse){
//console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + ', ' + response.email + '.');
username = response.name;
userid = response.id;
userEmail = response.email;
var ajaxRequest = new XMLHttpRequest();
ajaxRequest.onreadystatechange = function() {
if(ajaxRequest.readyState === 4 && ajaxRequest.status == 200) {
alert(ajaxRequest.responseText);
}
};
//send with POST fb_username=username&fb_userid=userid&fb_email=userEmail
ajaxRequest.open('GET','http://127.0.0.1/signup-portal/27340571/fb_action.php?fb_username='+username+'&fb_userid='+userid+'&fb_email='+userEmail+'&fb_mac='+userMac,true);
ajaxRequest.send(null);
window.location.href = "$(link-login-only)?dst=$(link-orig-esc)&username=T-$(mac-esc)";
});
} else {
alert('User cancelled login or did not fully authorize.');
showErrorScreen();
}
}, {scope: 'email,user_likes'});
//window.location.href = "//google.com";
}
function showErrorScreen() {
alert('showErrorScreen');
}
</script>
我的php页面有这段代码可以在数据库中发布数据
define('ZIL_ROOT', './');
// define this to stop other files being included when they shouldnt
define('scr_ind', true);
require_once 'include/db/connect.php';
$userPIN = $_GET['fb_userid'];
$password = 'tabanax';
$subscriber_email = $_GET['fb_email'];
$firstName = $_GET['fb_username'];
$subscriber_phone = $_GET['fb_mac'];
$sql3 = "INSERT INTO ".$configValues['CONFIG_DB_TBL_DALOUSERINFO'].
" (id, username,portalloginpassword, firstname, lastname, mobilephone, email, creationdate, creationby, enableportallogin, mng_hs_usr)".
" VALUES (0,'$userPIN','$password','".$firstName."','".$lastName."', '".$subscriber_phone."','".$subscriber_email."', ".
"'".NOW."','fb','1','".$configValues['CONFIG_HOTSPOT_BUSINESS_ID']."'".
")";
$res3 = mysql_query($sql3);