【问题标题】:Facebook social plugin on android安卓上的 Facebook 社交插件
【发布时间】:2013-05-10 07:44:47
【问题描述】:

我想集成 Facebook 的评论社交插件 (https://developers.facebook.com/docs/reference/plugins/comments/ 评论 url)进入我的 android 应用程序。 我尝试使用 webview (使用这个答案 Android unable to implement facebook comment in a webview due to default browser )并且它可以工作,但很难自定义,例如:我想要一个更大的文本框供用户输入评论。我的问题是:“是否有任何解决方案可以通过 facebook sdk、java 代码将诸如“Facebook 的评论社交插件”之类的内容集成到 android 应用程序中,以对 url 进行评论?

感谢和问候

【问题讨论】:

  • 你找到相同的解决方案了吗?

标签: android facebook-social-plugins


【解决方案1】:

据我了解,您有一些 URL 页面,您在其中嵌入了带有 cmets 的 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},您需要向 Graph 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 explorer https://developers.facebook.com/tools/explorer/

【讨论】:

  • 这是迄今为止我发现在尝试在本机应用程序中执行评论时完全控制 Graph API 的最佳方法之一。尽管您应该稍微更新一下最新更改的答案。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-10-23
  • 2011-12-19
  • 2012-08-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多