Multiple Photos upload on Facebook

后端 未结 1 1843
既然无缘
既然无缘 2020-12-30 16:39

Is there any way to upload multiple photos together on facebook... I have uploaded a single photo at a time using GraphAPI....but not multiple... Please suggest... Thanks...

相关标签:
1条回答
  • 2020-12-30 17:18

    You need to place a "batched" request to the Graph API. This is documented here: https://developers.facebook.com/docs/reference/api/batch/ (check out the paragraph "Uploading binary data"). Basically it's a cURL call where you json encode an array containing all the "batched" requests ("batch=[json array of calls]"). For some good reson Facebook limits your array to 20 requests. It translates pretty nicely to the PHP cURL methods, if you've got 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: replaced “ with " and ‘ with '

    0 讨论(0)
提交回复
热议问题