如何获取用户的帖子 [英] How to get posts of user

查看:122
本文介绍了如何获取用户的帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取墙上的信息,但是失败了。我正在使用Facebook sdk在代码页 http:// facebooksdk.codeplex.com/documentation
他们已经给出代码来获取帖子,但是当我替换我的令牌并更改

I was trying to get data of wall posts but failed .I am using facebook sdk at codeplex http://facebooksdk.codeplex.com/documentation they have given code to get posts but when i replace my token and change

dynamic result = app.Get("19292868552_118464504835613");

dynamic result = app.Get("/me/feed");

string fromName = result.from.name; throws异常,结果不存在。

the line string fromName = result.from.name; throws exception that from is not present in result.

然后我添加了一些断点,并在这里看到它们是图片

then i added some break point and watched them here is picture

您可以看到两个名为结果

you see the difference in two strings named me and result.

我工作正常,我可以提取任何我想要的东西,但结果没有帮助我注意到有|在导致问题的字符串剂量中。

me works fine and i can extract any thing i want but result dose not help i have noticed that there is "|" in the string dose that cause the problem.

推荐答案

由于数据是数组,因此您无法访问from.name。

You cannot access from.name as you showed because the data is an array.

可以试试这个。

var fb = new FacebookApp("access_token");
dynamic result = fb.Get("/me/feed");

foreach (dynamic post in result.data)
{
    var fromName = post.from.name;
    Console.WriteLine(fromName);
}

这篇关于如何获取用户的帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆