Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download attached file from Facebook using C# API

I able to download an image from facebook conversations using FB API but now i had a problem to download an attached file (.doc, .txt, .log and etc.) from facebook using graph FB API.

Json result return by Facebook if have attached file as below:

"message":"test sent attachment","attachments":{"data":[{"id":"10203275664207489","mime_type":"application/octet-stream","name":"service.log","size":432}]}},

Which is dont have any URL link to the file. But for image that json return by facebook contain url for the that picture. See Json below:

"message":"Gambaq","attachments":{"data":[{"id":"10203185045102068","mime_type":"image/jpeg","name":"10391434_10203185044782060_6466381862586755357_n.jpg","size":null,"image_data":{"width":720,"height":960,"is_sticker":false,"url":"https://fbcdn-sphotos-h-a.akamaihd.net/hphotos-ak-xpt1/v/t34.0-12/11304104_10203185045102068_881196838_n.jpg?

I use this API code for getting Json result:

    dynamic resultsByApi = fb.Get("/" + fbFanPage + "/conversations?access_token=" + tokenPage + "");

My question here is anybody know how to get attached file URL for facebook conversations using FB API?

Can anybody please help me to solve this issues. Thank you in advanced.

like image 200
Ifwat Ibrahim Avatar asked Nov 27 '14 04:11

Ifwat Ibrahim


1 Answers

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

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

With expected parameters are:

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


{"content_type":"image\/png","filename":"jagadeesh.png  ","file_size":14587,"data":<contents of data>}

its working v2.0 is expected..

also look at this fql details

like image 68
Jagadeesh Govindaraj Avatar answered Oct 19 '22 17:10

Jagadeesh Govindaraj