如何连接到Facebook和调试Facebook应用程序使用C#SDK [英] How to connect to facebook, and debug facebook application using C# SDK

查看:161
本文介绍了如何连接到Facebook和调试Facebook应用程序使用C#SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的很努力想找到的东西,实际工作获取的基本知识和运行。即使是与SDK附带的教程应用程序似乎有为了工作要上传,所以没有简单的方法来调试并在本地进行测试。



任何人有一个链接到一个工作示例我可以工作了吗?



干杯!





$ b $的b

这是我目前在我的aspx。有没有在后台代码:

 <%@页面语言=C#AutoEventWireup =真正的代码隐藏= WebForm1.aspx.cs中继承=FacebookTest.WebForm1%GT; 
<%@导入命名空间=脸谱%GT;

< D​​OCTYPE HTML PUBLIC - // W3C // DTD XHTML 1.0过渡// ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional! DTD>
< HTML的xmlns =htt​​p://www.w3.org/1999/xhtml的xmlns:FB =htt​​p://www.facebook.com/2008/fbml>
<头=服务器>
<标题>< /标题>
< /头>
<身体GT;
< P>
< / P>
<%VAR应用=新FacebookApp();
如果(app.Session == NULL)
{%GT;
< IMG ID =fbLoginSRC =登录-button.png/>
<%
}%GT;
< D​​IV ID =FB-根>< / DIV>
<脚本SRC =htt​​p://connect.facebook.net/en_US/all.js>< / SCRIPT>
<脚本>
FB.init({APPID:'<%:FacebookSettings.Current.AppId%GT;',状态:真的,饼干:真的,XFBML:真});
$('#fbLogin')。点击(函数(){
FB.login(功能(响应){
如果(response.session){
//窗口。位置='<% - :Url.Action(档案) - %GT;'
}其他{
//用户取消登录
}
}) ;
});
< / SCRIPT>

< /身体GT;
< / HTML>


解决方案

我也有此SDK战斗。对于本地测试,你必须做到以下几点




  1. 在Facebook应用程序的设置去网站选项卡并更改网站网址为HTTP://本地主机/

  2. 您还需要你的asp.net开发服务器的端口设置为80(写入单击项目,然后单击属性,请访问Web选项卡用户的Visual Studio开发服务器的特定端口)。我们这样做是因为我们设置我们网站的网址为localhost,Facebook的不要允许网站URL的端口号。


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.

Anyone got a link to a working sample I could work off of?

Cheers!


This is what I currently have in my 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. For local testing you must do the following

  1. In Facebook application settings go to Website tab and change site URL to "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). We are doing this because we set our site url to localhost, Facebook dont allow port number in site url.

这篇关于如何连接到Facebook和调试Facebook应用程序使用C#SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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