Facebook的C#SDK ASP.Net 3.5例子 [英] Facebook C# SDK ASP.Net 3.5 Examples
问题描述
我被要求开发一个Facebook应用程序,允许他们目前的系统的用户使用这个Facebook应用程序,以找到对方。 Unfortuantely其要求是,它必须建立在ASP.NET 3.5(更易于为他们的客户分发目的)。
我是一名经验丰富的PHP开发人员,虽然我已经在过去使用C#的Windows应用程序。我发现了一个Facebook的API,它看起来合适 - HTTP://facebooksdk.$c$cplex.com/ 一>。我遇到的问题是,所有availble的例子使用.NET 4。
我必须承认,我竭力去正视与API,我知道过去我学得最好通过实例。任何人都可以提供一个链接到实例或一些基本的code我尝试?
我真的AP preciate你对形势的任何意见或输入。 谢谢你,贾森。
更新
使用下面的答案,下面的资源(http://osnapz.word$p$pss.com/2010/04/23/using-asp-net-with-facebooks-graph-api-and-oauth-2-0-authentication/)这是很容易使开始的Facebook应用程序。
有一个问题我也有是服务器(1和1)我需要使用代理服务器设置添加到web.config
例如:
< system.net>
< defaultProxy>
<代理
usesystemdefault =假
bypassonlocal =假
proxyaddress =http://ntproxyus.lxa.perfora.net:3128
/>
< / defaultProxy>
< /system.net>
直到你成为更熟悉ASP.NET,我会建议用FacebookClient(积分),而不是更多地参与
一件事你必须明白的是动态
和使用的IDictionary
之间的差异。对于C#4.0,你就可以使用动态
,但3.5则必须使用旧的IDictionary
。
下面是如何从动态转换为IDictionary的(这样你就可以使用4.0例子作为指导)
一个很好的例子 变种FB =新FacebookClient({access_token});
动态结果= fb.Get(/我);
VAR名称= result.name;
回复于(你好+姓名);
转换为:
变种FB =新FacebookClient({access_token});
VAR的结果=(IDictionary的<字符串,对象>)fb.Get(/我);
VAR名称=(字符串)结果[名称];
回复于(你好+姓名);
我希望让你用自己的方式,只要转换的例子。
I've been asked to develop a facebook application that allows users of their current system to find each other using a this facebook app. Unfortuantely their requirements are that it has to be build in ASP.NET 3.5 (Easier for their clients distribution purposes).
I am a experienced PHP developer although I have in the past used C# for windows applications. I have found a facebook api that looks suitable - http://facebooksdk.codeplex.com/. The problem I am having is that all availble examples use .NET 4.
I must admit I'm struggling to get to grips with the api and I know from the past I learn best through example. Could anyone provide a link to examples or some basic code I experiment with?
I would really appreciate any advice or input you have on the situation. Thanks, Jason.
Update
Using the answer below and the following resource (http://osnapz.wordpress.com/2010/04/23/using-asp-net-with-facebooks-graph-api-and-oauth-2-0-authentication/) it is easy enough to make start on facebook application.
One issue I also had was the server (1&1) I was using needed proxy setting added to the web.config
Example:
<system.net>
<defaultProxy>
<proxy
usesystemdefault = "false"
bypassonlocal="false"
proxyaddress="http://ntproxyus.lxa.perfora.net:3128"
/>
</defaultProxy>
</system.net>
Until you become more familiar with ASP.NET, I would suggest integrating with the FacebookClient() rather than the more involved
the one thing you will have to understand is the difference between dynamic
and using IDictionary
. For C# 4.0 and up you can use dynamic
, but for 3.5 you must use the old IDictionary
.
Here's a good example of how to convert from dynamic to IDictionary (so you can use the 4.0 examples as a guide)
var fb = new FacebookClient("{access_token}");
dynamic result = fb.Get("/me");
var name = result.name;
Response.Write("Hi " + name);
Converts to:
var fb = new FacebookClient("{access_token}");
var result = (IDictionary<string, object>)fb.Get("/me");
var name = (string)result["name"];
Response.Write("Hi " + name);
I hope that gets you on your way as far as converting the examples.
这篇关于Facebook的C#SDK ASP.Net 3.5例子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!