1

我正在编写一个从用户 Facebook 通知中收集信息的应用程序。使用Graph Explorer,我要求:

me/notifications?include_read=true

这会返回一堆数据。每个项目都是您在登录 Facebook 时会看到的通知项目。例如(ID/名称略有变化):

{
  "id": "notif_630262196_168132987", 
  "from": {
    "name": "John Bloggs", 
    "id": "822724665"
  }, 
  "to": {
    "name": "Dermot Bloggs", 
    "id": "680265196"
  }, 
  "created_time": "2013-01-23T22:58:28+0000", 
  "updated_time": "2013-01-23T22:58:28+0000", 
  "title": "John Bloggs commented on your link: \"Goodbye Great Barrier Reef. Goodbye...\"", 
  "link": "http://www.facebook.com/<removed>/posts/330788937030559?comment_id=1702155", 
  "application": {
    "name": "Links", 
    "id": "2309869772"
  }, 
  "unread": 0, 
  "object": null
}

通知与评论有关,但如果“标题:”字段太长,则会被截断。

有没有一种干净的方法可以直接以编程方式访问评论,所以我可以获得所有文本,即使它是 1000 个字符的评论?

谢谢!:-)

4

2 回答 2

2

You should be able to get the comment by parsing the link field and querying:

/330788937030559_1702155

or

/POSTID_COMMENTID

When I tested this on my account, I am getting a comments object in the returned data, with the full text of the comments. I've got most permissions enabled in my Graph API. I suspect adding read_stream to the permissions is what will give you this data.

于 2013-01-24T01:47:55.207 回答
1

你可以避免解析!我一直在对通知进行大量实验,并获得了我所谓的“源”对象(源对象是发出通知的 Facebook 图形对象)。不幸的是,我找不到任何关于这种机制究竟是如何工作的文档,但如果您的应用程序已被授予大量权限,那么"object"您发布的 JSON 中的字段null实际上将填充“源对象”。而不仅仅是"object" : null它看起来像这样:

"object": {
    "id": "587140489_588632201147717", 
    "from": {
      "name": "Dave Rodríguez", 
      "id": "587140489"
    }, 
    "message": ":D ", 
    "picture": "https://fbcdn-vthumb-a.akamaihd.net/hvthumb-ak-prn1/632550_478955408819349_478954732152750_60483_1892_t.jpg", 
    "link": "https://www.facebook.com/photo.php?v=478954732152750", 
    "source": "http://video.ak.fbcdn.net/hvideo-ak-prn1/v/754708_478955348819355_1792301950_n.mp4?oh=c7295ccfc3773f24de931e4c29f512ce&oe=513F1728&__gda__=1363127340_9302c108824176369427a0b17491b800", 
    "name": "¡¡¡EL SECRETO DE LA CHANCLA!!!!", 
    "description": "EL SECRETO DE LAS MADRES, EL MÁS UTILIZADO EN TODAS LAS GENERACIONES, VÉALO USTED MISMO Y ((COMPARTA))!", 
    "properties": [
      {
        "name": "Length", 
        "text": "1:13"
      }
    ], 
    "icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yD/r/aS8ecmYRys0.gif", 
    "actions": [
      {
        "name": "Comment", 
        "link": "https://www.facebook.com/587140489/posts/588632201147717"
      }, 
      {
        "name": "Like", 
        "link": "https://www.facebook.com/587140489/posts/588632201147717"
      }
    ], 
    "privacy": {
      "value": ""
    }, 
    "type": "video", 
    "status_type": "shared_story", 
    "object_id": "478954732152750", 
    "application": {
      "name": "Video", 
      "namespace": "video", 
      "id": "2392950137"
    }, 
    "created_time": "2013-03-10T20:45:20+0000", 
    "updated_time": "2013-03-10T20:45:20+0000", 
    "likes": {
      "data": [
        {
          "name": "Adrian Guerra Cuenta Verificada", 
          "id": "674364748"
        }
      ], 
      "count": 1
    }, 
    "comments": {
      "count": 0
    }
  }

我希望比我更有知识的人能准确地告诉我们,我们需要什么权限才能看到这个字段被填充。我自己会弄清楚,但是权限太多,强制使用SUM(nCk(77,k),k,1,77)=151115727451828646838271可能的权限组合需要很长时间。

于 2013-03-10T21:56:47.987 回答