在线程中查看附件 [英] View attachments in threads

查看:28
本文介绍了在线程中查看附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在研究另一种查看线程和消息的方法.但是我在弄清楚如何显示附加到消息中的图像时遇到问题.

I'm currently working on an alternative way to view the threads and messages. But I have problems figuring out how to display the images attached to a message.

我对这个网址有一个 GET 请求:https://graph.facebook.com/t_id.T_ID/messages?access_token=ACCESS_TOKEN.并且响应包括

I have a GET request to this url: https://graph.facebook.com/t_id.T_ID/messages?access_token=ACCESS_TOKEN. And the response includes

"attachments": {
   "data": [
      {
         "id": "df732cf372bf07f29030b5d44313038c",
         "mime_type": "image/jpeg",
         "name": "image.jpg",
         "size": 76321
      }
   ]
}

但我找不到任何访问图像的方法.

but I can't find any way to access the image.

谢谢

推荐答案

对此的支持尚未添加到 Graph API 中,并且与许多其他消息传递 API 一样,它目前仅可用于测试(即您必须成为应用程序的开发者以立即使用它)

Support for this hasn't yet been added to the Graph API and as with many of the other messaging APIs, it's currently only avaialable for testing (i.e you must be a developer of the app to use it presently)

对此有一个未公开的 REST API 端点,它应该适用于任何应用程序(您是其开发者,如上所述).

There's an undocumented REST API endpoint for this, which should work for any app (that you're the developer of, as above).

使用REST方法获取附件数据是

To use the REST method to get the attachment data, it's

https://api.facebook.com/method/messaging.getattachment

带参数:

access_token=YOUR_ACCESS_TOKEN
mid=MESSAGE_ID
aid=ATTACHMENT_ID
format=json     //(it defaults to XML otherwise)

回复是这样的:

{"content_type":"image/png","filename":"Screen Shot 2012-02-08 at 11.35.35.png","file_size":42257,"data":<FILE CONTENTS>}

我刚刚测试了这个,它对我来说工作正常,使用 <FILE CONTENTS> 和 base64 解码它们给了我正确的原始图像

I've just tested this and it worked OK for me, taking the <FILE CONTENTS> and base64 decoding them gave me back the original image correctly

这篇关于在线程中查看附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆