通过 url 使用 Facebook 的 Graph API 上传托管图像?
因此,我使用 Facebook Graph API 上传照片。使用curl,它会像这样:
curl -F 'access_token={some access token}'
-F 'source=@/some/file/path/foo.png'
-F 'message=This is a test of programatic image uploading'
https://graph.facebook.com/me/photos
现在,如果我在发出请求的机器上有该文件,那么效果就很好。问题是我正在使用的系统将图像作为网址获取(例如“http://example.com/foo.png”)。我不想将图像从 example.com 下载到我的服务器只是为了将其上传到 facebook,因为除此之外我不需要保留它。有什么办法可以将网址传递给 Facebook,还是不可能?
(-F 'source=@http://example.com/foo.png' 不起作用)
So, I'm using the Facebook Graph API to upload a photo. Using curl, it goes something like this:
curl -F 'access_token={some access token}'
-F 'source=@/some/file/path/foo.png'
-F 'message=This is a test of programatic image uploading'
https://graph.facebook.com/me/photos
Now, this works fine if I have the file on the machine I'm making the request from. The issue is that the system I'm working on gets the image as a url (say, "http://example.com/foo.png"). I'd rather not download the image from example.com to my server just to upload it to facebook, since I have no need to keep it other than that. Is there any way I can just pass the url to facebook, or is this impossible?
(-F 'source=@http://example.com/foo.png' does not work)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
过去,我们只是将文件本地下载到服务器,然后处理上传并取消链接。通过这种方式,我们还能够确保资源可以(服务器/连接脱落)首先上传。我不相信您可以启动来自第三方的上传和媒体(尽管可能是错误的)。
In the past, we've simply downloaded the file locally to the server, then handled the upload and unlinked it. This way we're also able to be sure that the asset was available (servers/connections flaking out) to be uploaded in the first place. I don't believe you can initiate an upload and the media to come from a third-party (may be wrong though).