Facebook C# SDK ASP.Net 3.5 Examples

三世轮回 提交于 2019-12-01 12:28:13

问题


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>

回答1:


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.



来源:https://stackoverflow.com/questions/9017532/facebook-c-sharp-sdk-asp-net-3-5-examples

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!