facebook页面对话webhook获取消息内容

时间:2016-06-29 01:03:10

标签: facebook-graph-api facebook-javascript-sdk

当页面上有新消息(对话更改webhook)时,我会收到对话webhook,但如何获取该消息内容?以下是webhook的样子:

{"entry":[{"changes":[{"field":"conversations","value":{"thread_id":"t_mid.1467550763532:90df1b42684fd25a61","page_id":2959874586841}}],"id":"2959054086841","time":1467156268}],"object":"page"}

然后我可以做图形api请求(带有页面标记)到:

  

t_mid.1467150763538:90df162684fd25a69 /消息

我得到:

    {"data": [{"created_time": "2016-06-29T00:24:42+0000", "id": "m_mid.14671598826:009a97e7037f33c693"}, {"created_time": "2016-06-28T23:24:27+0000", "id": "m_mid.14671562658:cf5f62913d39905671"}, .... ], "paging": {"previous": "https://graph.facebook.com/v2.6/t_mid.1467150763538:90df62684fd25a69/messages?format=json&access_token=EAATq772LHHQBZAXXX&limit=25&since=1467159882&__paging_token=enc_AdXXX&__previous=1", "next": "https://graph.facebook.com/v2.6/t_mid.14671507538:90df1b6268d25a69/messages?format=json&access_token=ETXXX&limit=25&until=1467150763&__paging_token=enc_AXXX"} }

我的问题是:如何获取最近webhook的消息内容?我是否必须逐个浏览这些消息,看看我是否已将它们保存在我的数据库中?似乎应该有更好的方法。

1 个答案:

答案 0 :(得分:0)

使用thread_Id获取内容 例如:

<base href="/" />