我有 fblogin 到我的网站。我想将 ID、姓名和电子邮件保存到数据库。所以请告诉我如何将这些值从脚本传递到服务器。由于我没有太多经验,我不知道如何将值从脚本传递到服务器。如果可以从脚本 ta 服务器传递值。请告诉我解决方案。
下面我发布了我的完整编码
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Facebook Get Logged in User Details UserName,Email,Profile Image</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<script type="text/javascript">
// 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));
// Init the SDK upon load
window.fbAsyncInit = function() {
FB.init({
appId: 'XXXXX', // App ID
channelUrl: '//' + window.location.hostname + '/channel', // Path to your Channel File
status: true, // check login status
cookie: true, // enable cookies to allow the server to access the session
xfbml: true // parse XFBML
});
// listen for and handle auth.statusChange events
FB.Event.subscribe('auth.statusChange', function(response) {
if (response.authResponse) {
// user has auth'd your app and is logged into Facebook
//var uid = "http://graph.facebook.com/" + response.authResponse.userID + "/picture";
var uid = "http://graph.facebook.com/" + response.authResponse.userID + "/education ";
var uuu = "http://graph.facebook.com/me?education=" + response.authResponse.accessToken
FB.api('/me', function(me) {alert(me.first_name)
var Name = me.name;
var Email = me.email
})
document.getElementById('auth-loggedout').style.display = 'none';
document.getElementById('auth-loggedin').style.display = 'block';
} else {
// user has not auth'd your app, or is not logged into Facebook
document.getElementById('auth-loggedout').style.display = 'block';
document.getElementById('auth-loggedin').style.display = 'none';
}
});
$("#auth-logoutlink").click(function() { FB.logout(function() { window.location.reload(); }); });
}
</script>
<form id="form1" runat="server">
<h1>
Facebook Login Authentication </h1>
<div id="auth-status">
<div id="auth-loggedout">
<div class="fb-login-button" autologoutlink="true" scope=" user_checkins,user_website, user_relationship_details, user_hometown, user_religion_politics, user_education_history, user_about_me, user_birthday, user_status, publish_stream, user_photos, read_stream, friends_likes">Login with Facebook</div>
</div>
<div id="auth-loggedin" style="display: none">
<br />
Name:<b><span id="auth-displayname"></span></b>
(<a href="#" id="auth-logoutlink">logout</a>)<br />
First Name: <b><span id="firstname"></span></b><br />
Last Name: <b><span id="lastname"></span></b><br />
Email: <b><span id="Email"></span></b><br />
gender: <b><span id="gender"></span></b><br />
Dob of birth: <b><span id="birth"></span></b><br />
Location: <b><span id="location"></span></b><br />
</div>
</div>
</form>
</body>
</html>