我使用FB C#sdk 5.2.from http://facebooksdk.codeplex.com/ 并使用.net 3.5开发,所以我不能使用动态,var类型能够获取数据,但格式太难看了,很难得到我想要的数据。
我想知道如何使用Facebook.JSONObject或JSonArray存储数据,似乎没有这样的Dictionary [“data”]函数。 此外,我找不到文件
有什么想法? 非常感谢。
答案 0 :(得分:0)
如果你需要非法的尝试:
var fc = new FacebookClient("someAccessToken");
var result = (IDictionary<string, object>)fc.Get("/me/feed");
或类似的电话。
可选择举例说明您要检索和/或发布的内容?
或者您可以使用:
[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; }
}
和
var fc = new FacebookClient("someAccessToken");
var result = fc.Get<PostCrate>("/me/feed");
(以上任何属性均可省略)
DataMember名称基于上面IDictionary的“键”
答案 1 :(得分:0)
[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; }
}