1

我已经做了很多寻找答案,但我找不到一个。

我正在尝试使用图形 API 将单张照片上传到众多 Facebook 页面。

使用类似问题的答案,我能够得到我需要做的工作,就像这样;

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

这意味着对于我要发布照片的每个页面,我都必须上传照片的副本。我想做的是这样的;

curl 
 –F  'access_token=…' \
 -F  'batch=[{"method":"POST", \
          "relative_url":"me/photos", \
          "body":"message=Photo" \
          "attached_files":"file" \
         },
         {"method":"POST", \
          "relative_url":"me/photos", \
          "body":"message=Photo" \
          "attached_files":"file" \
         },
        ]’
 -F  'file=@/tmp/photo.gif' \
https://graph.facebook.com

这似乎不起作用,将上传一张照片,批处理中的其他请求将返回错误消息;

{"error":{"message":"(#1) An unknown error occurred","type":"OAuthException","code":1}}

如果我必须将同一张照片附加到批处理请求中,则每个请求一张。我也可以不使用批处理请求,而只为我想要上传照片的每个页面执行一个请求。

有人知道问题是什么吗?

4

0 回答 0