在Facebook Graph API Post文档中,将图像发布到墙(用户或页面)的唯一方法是在请求上提供图片字段。
所以我可以使用它并将图像从我的硬盘上传到服务器并使用该URL。 喜欢这个:
curl --form picture=http://userserve-ak.last.fm/serve/174s/66037848/Foals+png.png --form access_token=AAADChj --form message=msg1 https://graph.facebook.com/242001885843121/feed但是当我这样做时,帖子的类型字段被设置为“状态”而不是“照片”。
我尝试了一些不同的东西,例如使用相同的请求参数将图像上传到相册但没有成功:
curl --form picture=@/tmp/fb_gallery.png --form access_token=AAADChj --form message=msg2 https://graph.facebook.com/242001885843121/feed curl --form source=@/tmp/fb_gallery.png --form access_token=AAADChj --form message=msg2 https://graph.facebook.com/242001885843121/feed我试图将类型字段设置为“照片”,但也没有运气。
On the Facebook Graph API Post documentation the only way of posting images to a wall (user's or page's) is by providing the picture field on the request.
So I could use that and upload the image from my hard-disk to a server and use that url. Like this:
curl --form picture=http://userserve-ak.last.fm/serve/174s/66037848/Foals+png.png --form access_token=AAADChj --form message=msg1 https://graph.facebook.com/242001885843121/feedBut when I do that the type field of the post gets set as "status" and not as "photo".
I tried some different things like using the same request parameters used for uploading an image to an album with no success:
curl --form picture=@/tmp/fb_gallery.png --form access_token=AAADChj --form message=msg2 https://graph.facebook.com/242001885843121/feed curl --form source=@/tmp/fb_gallery.png --form access_token=AAADChj --form message=msg2 https://graph.facebook.com/242001885843121/feedI tried to set the type field to "photo" with no luck also.
最满意答案
试试这个,它可以一次上传2张照片
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.comTry out with this one it can upload 2 photos at a time
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更多推荐
发布评论