代码隐藏中的facebook详细信息 [英] facebook details in codebehind
本文介绍了代码隐藏中的facebook详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在网站上使用Facebook登录,该登录仅适用于开发人员帐户登录,因此如何解决该问题以及如何获取有关背后代码的用户电子邮件.
我使用的代码是:
i am using facebook login on website which works only for developer account to login, so how to resolve it and how to get user email on code behind.
code I used is:
<div id="fb-root"></div>
<h2>Updated JS SDK example</h2><br />
<div id="user-info"></div>
<p><button id="fb-auth">Login</button>
<label id="lbemail" runat="server"></label>
</p>
<script type="text/javascript">
window.fbAsyncInit = function () {
FB.init({ appId: ''API'',
status: true,
cookie: true,
xfbml: true,
oauth: true
});
function updateButton(response) {
var button = document.getElementById(''fb-auth'');
var email = document.getElementById(''lbemail'');
if (response.authResponse) {
//user is already logged in and connected
var userInfo = document.getElementById(''user-info'');
FB.api(''/me'', function (response) {
userInfo.innerHTML = ''<img src="https://graph.facebook.com/''
+ response.id + ''/picture">'' + response.name + response.user_location;
email.innerHTML = response.email;
button.innerHTML = ''Logout'';
});
button.onclick = function () {
FB.logout(function (response) {
var userInfo = document.getElementById(''user-info'');
userInfo.innerHTML = "";
});
};
} else {
//user is not connected to your app or logged out
button.innerHTML = ''Login'';
button.onclick = function () {
FB.login(function (response) {
if (response.authResponse) {
FB.api(''/me'', function (response) {
var userInfo = document.getElementById(''user-info'');
userInfo.innerHTML =
''<img src="https://graph.facebook.com/''
+ response.id + ''/picture" style="margin-right:5px"/>''
+ response.name;
});
} else {
//user cancelled login or did not grant authorization
}
}, { scope: ''email'' });
}
}
}
// run once with current status and whenever the status changes
FB.getLoginStatus(updateButton);
FB.Event.subscribe(''auth.statusChange'', updateButton);
};
(function () {
var e = document.createElement(''script''); e.async = true;
e.src = document.location.protocol
+ ''//connect.facebook.net/en_US/all.js'';
document.getElementById(''fb-root'').appendChild(e);
} ());
</script>
推荐答案
您可以在CP中找到许多文章,因此请在此处浏览
Facebook文章@ Codeproject [
You can find many articles in CP so browse here
Facebook articles @ Codeproject[^](109 results)
这篇关于代码隐藏中的facebook详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文