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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With