简体   繁体   English

如何连接到Facebook,并使用C#SDK调试Facebook应用程序

[英]How to connect to facebook, and debug facebook application using C# SDK

I'm really struggling trying to find something that actually works for getting the basics up and running. 我真的在努力寻找能够让基础知识正常运行的东西。 Even the tutorial apps that came with the SDK seems to have to be uploaded in order to work, so there's no easy way to debug and test it locally. 即使SDK附带的教程应用程序似乎也必须上传才能工作,因此没有简单的方法可以在本地进行调试和测试。

Anyone got a link to a working sample I could work off of? 任何人都有一个链接到我可以工作的工作样本?

Cheers! 干杯!


This is what I currently have in my aspx. 这是我目前在我的aspx中所拥有的。 There's nothing in the code-behind: 代码隐藏中没有任何内容:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="FacebookTest.WebForm1" %>
<%@ Import Namespace="Facebook" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head runat="server">
    <title></title>
</head>
<body>
    <p>
    </p>
    <% var app = new FacebookApp();
       if (app.Session == null)
       {%>
        <img id="fbLogin" src="login-button.png" />
            <%
       }%>
    <div id="fb-root"></div>
    <script src="http://connect.facebook.net/en_US/all.js"></script>
    <script>
        FB.init({ appId: '<%:FacebookSettings.Current.AppId %>', status: true, cookie: true, xfbml: true });
        $('#fbLogin').click(function () {
            FB.login(function (response) {
                if (response.session) {
                    //window.location = '<%--:Url.Action("Profile") --%>'
                } else {
                    // user cancelled login
                }
            });
        });
    </script>

</body>
</html>

I am also fighting with this sdk. 我也在和这个sdk战斗。 For local testing you must do the following 对于本地测试,您必须执行以下操作

  1. In Facebook application settings go to Website tab and change site URL to "http://localhost/" 在Facebook应用程序设置中,转到“网站”选项卡,将站点URL更改为“http:// localhost /”
  2. You also need to set your asp.net development server port to 80 (write click your project and click properties, go to Web tab User Visual Studio Development server specific port). 您还需要将您的asp.net开发服务器端口设置为80(单击您的项目并单击属性,转到Web选项卡用户Visual Studio开发服务器特定端口)。 We are doing this because we set our site url to localhost, Facebook dont allow port number in site url. 我们这样做是因为我们将我们的网站网址设置为localhost,Facebook不允许网站网址中的端口号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM