开发者

Facebook SDK C#

I am trying to parse the facebook api via someid/feed api using Facebook SDK C#. But I cannot parse the keys quite right. Does anyone have an example of how this should work?

dynamic fb = new FaceBookClient(token);
dynamic feed = fb.Get("123456/feed");
var msg = feed.message; // (do not get intellisense)

or

var msg = feed["message]; //(returns No data key found error开发者_Python百科.)


You need to pass also appId and appSecret to FaceBookClient. So instead of picking up a constructor, do the settings in Web.Config:

<facebookSettings appId="123" appSecret="abc" siteUrl="..." canvasPage="..." canvasUrl=".." cancelUrlPath="..." />

then try:

FacebookWebClient fbWebClient = new FacebookWebClient();                    
dynamic result = fbWebClient.Get("123456/feed");


Feed returns a JSON Array wrapped in a result object. Get the result object by calling feed.First(), then loop through the JsonArray to get the individual posts.

const string url = "/me/feed";
IDictionary<string, object> feed = FacebookClient.Get(url, parameters);
JsonArray posts = feed.First().Value as dynamic;
return posts;


It is so simple as I see.

public dynamic GetFeeds()
{
   dynamic feeds = facebookClientProvider.CreateOne().Get("/me/feed");
   //feeds.data
   //feeds.paging

   return feeds;
}

The feeds.data will contain the feeds and the data.paging will contain a url where you can download the following feeds.

I'm using Facebook C#SDK Runtime version:v4.0.30319 and Version:6.0.10.0

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜