I use the FB C# sdk 5.2.from http://facebooksdk.codeplex.com/ and develop with .net 3.5, so i cannot use the dynamic, and the var type is able to get the data, but the format is so ugly and hard to get the data i want.
I want to know how to store data with the Facebook.JSONObject or the JSonArray, it seems like there is开发者_高级运维 no such a Dictionary["data"]function. Besides, i cannot find the document
Any thoughts? Thanks a lot.
If you need distionary try:
var fc = new FacebookClient("someAccessToken");
var result = (IDictionary<string, object>)fc.Get("/me/feed");
or similar call.
Optionally give an example of what are you trying to retrieve and/or post?
Or you may use:
[DataContract]
public class PostCrate
{
[DataMember(Name = "data")]
public List<Post> Data { get; set; }
[DataMember(Name = "paging")]
public Paging Paging { get; set; }
}
[DataContract]
public class Paging
{
[DataMember(Name = "previous")]
public string Previous { get; set; }
[DataMember(Name = "next")]
public string Next { get; set; }
}
[DataContract]
public class Post
{
[DataMember(Name = "id")]
public string ID { get; set; }
[DataMember(Name = "from")]
public BaseUser From { get; set; }
[DataMember(Name = "type")]
public string Type { get; set; }
[DataMember(Name = "created_time")]
public string CreatedTime { get; set; }
[DataMember(Name = "updated_time")]
public string UpdatedTime { get; set; }
}
[DataContract]
public class BaseUser
{
[DataMember(Name = "id")]
public string ID { get; set; }
[DataMember(Name = "name")]
public string Name { get; set; }
}
and
var fc = new FacebookClient("someAccessToken");
var result = fc.Get<PostCrate>("/me/feed");
(any properties above can be omited)
DataMember names are base on 'keys' from IDictionary above
[DataContract]
public sealed class Group
{
[DataMember(Name = "name")]
public string Name { get; set; }
[DataMember(Name = "privacy")]
public string Privacy { get; set; }
[DataMember(Name = "id")]
public string Id { get; set; }
}
精彩评论