我想整合Facebook的评论社交插件 (https://developers.facebook.com/docs/reference/plugins/comments/评论网址)进入我的Android应用程序。 我尝试使用webview(使用这个答案Android unable to implement facebook comment in a webview due to default browser)并且它很有用,但很难自定义,例如:我希望有一个更大的文本框供用户输入注释。我的问题是:“是否有任何解决方案可以通过facebook sdk,java代码将”Facebook的评论社交插件“整合到Android应用程序中,以便对网址发表评论?
谢谢&最好的问候
答案 0 :(得分:1)
据我所知,你有一些URL页面,你已经在其中嵌入了带有评论的facebook社交插件,你想要解析它并显示你想要的内容。如果我是对的,那么遗憾的是我没有通过触发Facebook SDK中的适当方法找到简单的解决方案。您必须使用Graph API。
首先,我们需要查看文档 - https://developers.facebook.com/docs/graph-api/reference/v2.3/object/comments
这里有一个电话
的例子/* make the API call */
new Request(
session,
"/{object-id}/comments",
null,
HttpMethod.GET,
new Request.Callback() {
public void onCompleted(Response response) {
/* handle the result */
}
}
).executeAsync();
要获取 {object_id} ,您需要向图谱API发送类似的调用,但是要检索ID:
GET-> ?id=http%3A%2F%2Fwww.imdb.com%2Ftitle%2Ftt2015381%2F
您将收到类似
的回复 {
"og_object": {
"id": "10150298925420108",
"description": "Directed by James Gunn. With Chris Pratt, Vin Diesel, Bradley Cooper, Zoe Saldana. A group of intergalactic criminals are forced to work together to stop a fanatical warrior from taking control of the universe.",
"title": "Guardians of the Galaxy (2014)",
"type": "video.movie",
"updated_time": "2015-05-15T14:52:46+0000",
"url": "http://www.imdb.com/title/tt2015381/"
},
"share": {
"comment_count": 4,
"share_count": 91073
},
"id": "http://www.imdb.com/title/tt2015381/"
}
10150298925420108是我们的 object_id
所以下一个查询看起来像GET -> 10150298925420108/comments
和回应
{
"data": [
{
"id": "10150298925420108_10152457293990108",
"can_remove": false,
"created_time": "2014-10-28T18:12:15+0000",
"from": {
"id": "1513986108857171",
"name": "ซอโซ่ สระอา ยอยัก"
},
"like_count": 2,
"message": "สนุกมากค่ะ",
"user_likes": false
},
{
"id": "10150298925420108_10152457392770108",
"can_remove": false,
"created_time": "2014-10-28T19:20:28+0000",
"from": {
"id": "302917246580502",
"name": "สมชาย โกทันธ์"
},
"like_count": 0,
"message": "สองดาวครับ\n",
"user_likes": false
},
{
"id": "10150298925420108_10152461977130108",
"can_remove": false,
"created_time": "2014-10-31T11:57:10+0000",
"from": {
"id": "472810482857795",
"name": "Surat Thaenphet"
},
"like_count": 0,
"message": "แต่ละเรื่องที่ลง สนุกมาก แต่ดูไม่จบ ดูสักพัก ก็ eror ไม่รุ้เป็นเพราะอะไร",
"user_likes": false
}
],
"paging": {
"cursors": {
"before": "Mw==",
"after": "MQ=="
}
}
}
要在Android应用中执行此测试之前测试所有这些请求和响应,请使用Graph API资源管理器https://developers.facebook.com/tools/explorer/