Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View attachments in threads

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.

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.

Thanks

like image 616
ThoKra Avatar asked Feb 08 '12 11:02

ThoKra


People also ask

How do I view attachments in an email thread?

Click on View >Conversation Settings and select >Always Expand Conversations. That shows you the individual items with accessible attachments but still grouped as a conversation.

Why can't I see attachments in email threads?

This is because the way the email was originally created and filed (including the attachments) as a thread. The only way to preview these attachments is using Export (refer to Exporting Documents) and to look at the attachments in the downloaded email.

How do I find attachments in Outlook thread?

The simplest way to display Outlook's search tools is to click in the Search Current Mailbox box at the top of the message list. Once you place your cursor in that box, the ribbon will display the Search Tools options. To find all messages with attachments, select the Has Attachments button.

How do I view attachments in a Gmail thread?

Start from the advanced Gmail search box. Click in the check box to left of the Has attachment field: Search for emails that have attachments. To complete the search, click the magnifying glass icon in the lower left of the advanced Gmail search box. Your search results appear.


1 Answers

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)

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

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

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

With parameters:

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

The response is like this:

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

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

like image 87
Igy Avatar answered Mar 03 '23 01:03

Igy