【发布时间】:2017-02-06 14:52:13
【问题描述】:
我想从网页中检索嵌入的 Facebook cmets:
(http://www.example.com/sub_page_wFBcomments)
我所知道的
我可以使用 Facebook 图形 API 直接从 facebook.com 检索 facebook cmets。 当 cmets 嵌入 facebook 页面所有者的网站时,情况并非如此。
我的尝试
当像这样使用图形 API 时:
https://graph.facebook.com/v2.7/[apikey]/?key=value&access_token=[MyToken]
{
"link": "http://www.example.con/",
"name": "Example.com",
"namespace": "examplecom",
"id": "[apikey]"
}
当天真地适应 cmets 时: [链接]https://graph.facebook.com/v2.7/[apikey]/posts/?key=value&access_token=[MyToken]
它不起作用,我明白了:
"message": "(#100) Tried accessing nonexisting field (posts) on node type (Application)",
"type": "OAuthException",
Facebook 页面没有可显示的 cmets/帖子。 (但是当做 [apikey] = walmart 时,它会下载 facebook 页面的 cmets) 所以我推断缺少一些东西:api如何知道在哪里寻找cmets?
我走了多远:
Stackoverflow 建议使用类似的东西
/comments/?ids= "link of page"
这不起作用:
https://graph.facebook.com/v2.7/[apikey] /cmets/?ids=http://www.example.com/sub_page_wFBcomments&access_token=[MyToken]
"message": "(#100) Tried accessing nonexisting field (comments) on node type (Application)",
备注 从上一个 url 中删除“/comments”时,我恢复了 .json 中的正文,但不是 cmets。
问题:
是否可以让 api 在 中查找 cmets? http://www.example.com/sub_page_wFBcomments (而不是来自 www.facebook.com/exemplecom)
感谢您的帮助。
编辑
根据@CBroe 的评论,我已经尝试了有关示例的常见问题解答
http://www.oneminuteinfo.com/2015/06/how-to-use-fb-api-to-get-fan-page-posts.html
https://graph.facebook.com/v2.6/?fields=og_object{comments}&id=http://www.url.com&access_token=[MyToken]
{
"og_object": {
"id": "1305277432850801"
},
"id": "http://www.oneminuteinfo.com/2015/06/how-to-use-fb-api-to-get-fan-page-posts.html"
}
评论不见了:(
编辑 2
感谢@TomSanders 的回答。我尝试了您的建议,但仍然无法正常工作,我使用 url 检索到的 id 不是给 cmets 的,我自己解释一下:
来自
https://graph.facebook.com/v2.3/[myUrl]/comments?limit=100&access_token=[myToken]
我明白了:
{
"og_object": {
"id": "813606582071724",
"description": "the description",
"title": "the title",
"type": "website",
"updated_time": "2016-10-15T16:57:59+0000"
},
"share": {
"comment_count": 0,
"share_count": 0
},
"id": "myUrl"
}
备注1将url地址从http更改为https时,“comment_count”变为= 141。
备注 2 使用此请求在下一步中获得的 id 检索一个空数据:{"data":[]}。
备注 3 (!!) 右键单击网站的 facebook 插件时,我会通过查找 targetid = 1065663070140433 来获取 facebook id。然后,当我将其插入 api 时,我获得(一些)cmets!
我在这里做错了什么?我需要灯。
【问题讨论】:
-
您是指嵌入了 FB 评论插件的页面?社交插件常见问题解答中描述了如何获取这些内容。
-
@CBroe 我看到 cmets 说用一个真实的例子来说更简单。我正在尝试从网站获取 Facebook cmets(来自插件):oneminuteinfo.com/2015/06/…
-
网址错误。去查看该站点的源代码以找出 cmets 插件实际指向的内容。
-
感谢您的回答,但我一无所知。我一直在上下阅读网址,但看不到插件指向的位置。它在某个脚本块中吗?
-
不,它存在于用于在该位置呈现 cmets 的元素中,即类为
fb-comments的元素。
标签: facebook facebook-graph-api web-scraping