Facebook API:评论/点赞数据的数据转储
这是我的代码:
string code = Request.QueryString["code"];
string appId = "x";
string appSecret = "x";
if (code == "" || code == null)
{
//request for authentication
Response.Redirect("https://graph.facebook.com/oauth/authorize?client_id=" + appId + "&redirect_uri=http://localhost:62543/&scope=email,read_stream");
}
else
{
var fb = new MyFB();
fb.ApplicationSecret = appSecret;
fb.ApplicationID = appId;
string accessToken = fb.GetAccessToken(code);
fb.AccessToken = accessToken;
var fbc = new FacebookClient(accessToken);
dynamic streams = fbc.Query("select post_id from stream where permalink = 'http://www.facebook.com/kevin.clough/posts/882439437244'");
Response.Write(streams.Count);
dynamic results = fbc.Query("select comments, likes from Post where id = " + streams.post_id);
foreach (dynamic comment in results.comments)
{
Response.Write(comment.from.name + ", " + comment.message + "<br/>");
}
}
收到此错误“当使用与会话所有者不同的viewer_id查询流表时,无法使用会话。”
我如何授权此会话查看我自己的数据?
Here is my code:
string code = Request.QueryString["code"];
string appId = "x";
string appSecret = "x";
if (code == "" || code == null)
{
//request for authentication
Response.Redirect("https://graph.facebook.com/oauth/authorize?client_id=" + appId + "&redirect_uri=http://localhost:62543/&scope=email,read_stream");
}
else
{
var fb = new MyFB();
fb.ApplicationSecret = appSecret;
fb.ApplicationID = appId;
string accessToken = fb.GetAccessToken(code);
fb.AccessToken = accessToken;
var fbc = new FacebookClient(accessToken);
dynamic streams = fbc.Query("select post_id from stream where permalink = 'http://www.facebook.com/kevin.clough/posts/882439437244'");
Response.Write(streams.Count);
dynamic results = fbc.Query("select comments, likes from Post where id = " + streams.post_id);
foreach (dynamic comment in results.comments)
{
Response.Write(comment.from.name + ", " + comment.message + "<br/>");
}
}
Getting this error "A session cannot be used when querying the stream table with a viewer_id that is a different from the session owner."
How do I authorize this session to view my own data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以我看到的第一个问题是查询无效。您有:
根据 Facebook 文档此处,您只能使用以下命令查询流表:列 post_id、app_id、source_id、filter_key 和 xid。
因此,您应该将第一个查询更改为此(使用帖子 ID '19292868552_118464504835613' 作为示例):
或者,您可以使用帖子 id 对图表执行相同的操作:
您的第二个查询是错误的,主要是因为您正在查询一个表不存在。
没有这样的 FQL 表“Post”。我不确定这样做的目的是什么,但如果你想获得点赞和评论,我认为使用 Graph API 会更容易。
评论:
喜欢:
这是 Facebook 关于 Post Graph API 的文档:http://developers。 facebook.com/docs/reference/api/post/
编辑:
要确定用户的流项目,您需要阅读他们的提要。您也可以使用 Graph API 来完成此操作。
这将为您提供该用户的最新帖子。从那里您可以循环浏览它们以找到您想要获得更多详细信息的那个。
So the first problem I see is that the query is not valid. You have:
Per the Facebook documentation here you can only query the stream table using the columns post_id, app_id, source_id, filter_key, and xid.
So you should change your first query to this (using post ID '19292868552_118464504835613' as an example):
Alternatively, you could do the same thing with the graph using the post id:
Your second query is wrong mainly because you are querying a table that doesn't exist.
There is no such FQL table 'Post'. I am not sure what the goal of this is, but if you want to get the likes and comments I think it would be easier to use the Graph API.
Comments:
Likes:
Here is Facebook's documentation on the Post Graph API: http://developers.facebook.com/docs/reference/api/post/
EDIT:
To determine the stream items of a user you will want to read their feed. You can do this using the Graph API also.
This will get you the most recent posts of the user. From there you can loop through them to find the one you want to get more details.