Download attachment from Facebook using C # API

I can download the image from facebook conversations using the FB API, but now I have a problem downloading the attached file (.doc, .txt, .log, etc.) from facebook using the graphical FB API.

The result Json returns to Facebook if the file is attached below:

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

Which does not have a URL to the file. But for the image that json returns facebook contains url for this 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-ha.akamaihd.net/hphotos-ak-xpt1/v/t34.0-12/11304104_10203185045102068_881196838_n.jpg? 

I use this API code to get the Json result:

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

My question is here, does anyone know how to get the attached url for facebook conversations using the FB API?

Can anyone help me solve these problems. Thank you for your promotion.

+7
c # facebook download facebook-graph-api webclient-download
source share
1 answer

To use the REST method to get attachment data, this

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

With expected parameters:

 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 information.

+2
source share

All Articles