Upload multiple photos to Facebook

Is there a way to upload multiple photos to facebook ... I uploaded one photo at a time using GraphAPI .... but not several ... Please suggest ... Thanks ...

+4
source share
1 answer

You need to put the "batch" request in the Graph API. This is described here: https://developers.facebook.com/docs/reference/api/batch/ (see the paragraph “Downloading binary data”). Basically this is a cURL call in which you json encode an array containing all the "batch" requests ("batch = [json array of calls]"). For some good resonances, Facebook limits your array to 20 requests. This works very well for PHP cURL methods if you have cURL enabled on your server ...

curl –F 'access_token=…' \ -F 'batch=[{"method":"POST", \ "relative_url":"me/photos", \ "body":"message=My cat photo" \ "attached_files":"file1" \ }, {"method":"POST", \ "relative_url":"me/photos", \ "body":"message=My dog photo" \ "attached_files":"file2" \ }, ]' -F ' file1=@cat.gif ' \ -F ' file2=@dog.jpg ' \ https://graph.facebook.com 

UPDATE: replace "by" and "by"

+2
source

Source: https://habr.com/ru/post/1346016/


All Articles