使用asp.net获取有关单击按钮的Facebook登录详细信息 [英] Get Facebook login detail on button click using asp.net

查看:71
本文介绍了使用asp.net获取有关单击按钮的Facebook登录详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,我在c#.net中具有以下页面,可在我的网站上获取Facebook的详细信息.这对我来说很好.唯一的问题是,如果我登录Facebook并在同一浏览器中打开此页面,则该页面将自动运行,而无需单击按钮.我的要求是,当我单击使用Facebook登录"时,它只能工作,否则不能.

请告诉我这怎么可能.

Hi.. Friends, I have the following page in c#.net to get Facebook detail on my website. It is working very fine for me. The only problem is that, if I am login with Facebook and open this page in same browser then it working automatically without my click on the button. My requirement is that when I click on Login with Facebook it work only then oterwise not.

Please tell me how it is possible.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

</script>

<html>
<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>
// 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: '***************', // Your 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";
            FB.api('/me', function(me) {
                document.getElementById('auth-displayname').innerHTML = me.name;
                document.getElementById('Email').innerHTML = me.email;
                document.getElementById('profileImg').src = uid;
                document.getElementById('DOB_User').innerHTML = me.birthday;
                document.getElementById('City').innerHTML = response.authResponse.userID;
                document.getElementById('Gender_User').innerHTML = me.gender;                
            })
            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>
<h1>
Facebook Login Authentication Example</h1>
<form id="form1" runat="server">
<div id="auth-status">
<div id="auth-loggedout">
<div class="fb-login-button" autologoutlink="false" scope="email,user_birthday">Login with Facebook</div>
</div>
<div id="auth-loggedin" style="display: none">

Name: <span id="auth-displayname"></span>(<a href="#" id="auth-logoutlink">logout</a>)<br />
Email: <span id="Email"></span><br />
Profile Image: <img id="profileImg" /><br />
D.O.B. : <asp:Literal  ID="DOB_User"></asp:Literal><br />
City : <asp:Literal id="City"></asp:Literal>
Gender : <asp:Literal  ID="Gender_User"></asp:Literal>

</div>
<asp:ImageButton ImageUrl="~/images/button/imgFbSignUp.jpg" runat="server"  OnClientClick="login()" />
</div>
</form>
</body>
</html>



在此先感谢

Parveen Rathi



Thanks in advance

Parveen Rathi

推荐答案

(" ).click(function(){FB.logout(function(){window.location.reload();});}); } </ 脚本 > < h1 > Facebook登录身份验证示例< /h1 > < 表单 =" form1" runat >服务器" > < div =" auth-status" < div =" auth-loggedout" < div =" fb-login-button" autologoutlink =" false" 范围 电子邮件,用户生日" < ; /div > < /div > < div =" auth-loggedin" 样式 显示:无" > 名称: < span id =" > < /span > (< a href =" id = " > logout < /a > )< ; br / > 电子邮件: < span id =" > < /span < / > 个人资料图片:< img id =" / < br / > D.O.B. : < asp:Literal ID =" DOB_User" < > br / < asp:Literal id =" > < /asp:Literal > 性别: < asp:Literal ID =" 性别用户" < > < /div > < asp:ImageButton ImageUrl =" span> runat =" 服务器" OnClientClick =" / > < /div > < /form > < /body > < /html >
("#auth-logoutlink").click(function() { FB.logout(function() { window.location.reload(); }); }); } </script> <h1> Facebook Login Authentication Example</h1> <form id="form1" runat="server"> <div id="auth-status"> <div id="auth-loggedout"> <div class="fb-login-button" autologoutlink="false" scope="email,user_birthday">Login with Facebook</div> </div> <div id="auth-loggedin" style="display: none"> Name: <span id="auth-displayname"></span>(<a href="#" id="auth-logoutlink">logout</a>)<br /> Email: <span id="Email"></span><br /> Profile Image: <img id="profileImg" /><br /> D.O.B. : <asp:Literal ID="DOB_User"></asp:Literal><br /> City : <asp:Literal id="City"></asp:Literal> Gender : <asp:Literal ID="Gender_User"></asp:Literal> </div> <asp:ImageButton ImageUrl="~/images/button/imgFbSignUp.jpg" runat="server" OnClientClick="login()" /> </div> </form> </body> </html>



在此先感谢

Parveen Rathi



Thanks in advance

Parveen Rathi


您好,请检查这里,这可能对您有帮助.

http://onlinewebapplication.com/2012/05/facebook-login-sign-in.html [ ^ ]
Hi please check here might be this will helpful for you.

http://onlinewebapplication.com/2012/05/facebook-login-sign-in.html[^]


这篇关于使用asp.net获取有关单击按钮的Facebook登录详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆