如何使用Facebook注册和登录或连接到我的asp.net网站?

问题描述:

任何一个可以给我一个最好的例子网站网址使用如何使用Facebook连接或Facebook注册到我的网站或Facebook登录使用asp.net网站?

can any one give me a best example site URL to using how to use facebook connect or facebook signup into my site or facebook login with asp.net site?

其实我的要求是,当我注册到我的asp.net网站受当时使用Facebook,我们想从Facebook和名字和姓氏也与用户的Facebook的图像用户的用户名(EMAILID)。

actually my requirement is that when i registered into my asp.net site by using facebook at that time we want to get facebook user's username (emailid) from facebook and firstname and last name also with user image.

使用Facebook的JavaScript SDK,因为使用JavaScript SDK你可以在Facebook上做干啥容易。
我给你一些code为例来做到这一点。

use facebook javascript SDK because by using javascript SDK you can do anythin on facebook easily. I am given you some code example to do this

<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>
<div id="fb-root">
    </div>
    <script type="text/javascript">
        FB.init({
            appId: '012341352533212',
            status: true, // check login status
            cookie: true, // enable cookies to allow the server to access the session
            xfbml: true, // parse XFBML
            channelUrl: 'http://www.xyz.com/channel.html', // channel.html file
            oauth: true // enable OAuth 2.0
        });
    </script>

这code打电话给你的Facebook应用程序

this code call your facebook application

 <script type="text/javascript">
        function facebookLogin() {
            FB.login(function (response) {
                if (response.authResponse) {
                    FB.api('/me', function (response) {
                        jQuery('#txtFirstName').val(response.first_name);
                        jQuery('#txtLastName').val(response.last_name);
                        jQuery('#txtEmail').val(response.email);
                        jQuery('#hdfUID').val(response.id);
                        //                        FB.logout(function (response) {
                        //                        });
                    });
                } else {
                    jQuery('#txtFirstName').val('');
                    jQuery('#txtLastName').val('');
                    jQuery('#txtEmail').val('');
                    jQuery('#hdfUID').val('');
                }
            }, { scope: 'email' });
            return false;
        }
    </script>

和Facebook的这个code调用登录页面,它响应你回来的用户ID,第一个名字。姓氏和特定用户的电子邮件,并使用jquery保存文本或hiddenfield这些价值和获得服务器端code页面上的这些值。

and this code call login page of facebook and it response you get back userid, first name. last name and email of the particular user and by using jquery save these values in textbox or hiddenfield and get these values on server side code page.