如何使用facebook graph api直接从磁盘在用户的墙上发布图像?(How to post an image on an user's wall directly from dis

编程入门 行业动态 更新时间:2024-10-23 11:19:34
如何使用facebook graph api直接从磁盘在用户的墙上发布图像?(How to post an image on an user's wall directly from disk using the facebook graph api?)

在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/feed

But 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/feed

I 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.com

Try 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

更多推荐

本文发布于:2023-07-05 06:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1034378.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   磁盘   墙上   图像   用户

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!