从本地存储上传Facebook图像 [英] Facebook image upload from local storage
问题描述
我正在使用Facebook graph API将图像发布到页面上.
I'm using Facebook graph API to post an Image to a page.
UploadImage() {
let params = {
url: "https://www.facebook.com/images/fb_icon_325x325.png",
published: true,
access_token: this.accessToken
};
this.fb.api('/543337362691456/photos', 'post', params).then().catch(this.handleError); }
此代码运行完美.但我想从计算机中选择一个文件,然后将该图像上传到Facebook.为此,我如何将本地文件的url设置为
This code works perfectly. But I want to select a file from computer and upload that image to facebook. In order to do that, How I'm suppose to set the url of a local file to
url:" "
如果我只是选择文件路径,则会显示错误
if I just select the path of a file it gives an error
推荐答案
url
参数仅用于在线/公共照片,该照片必须已经在服务器上.看一下API参考,您也可以将它们作为multipart/form-data
上传: https://developers.facebook.com/docs/graph-api/reference/page/photos/#Creating
The url
parameter is for online/public photos only, the picture needs to be on a server already. Take a look at the API reference, you can also upload them as multipart/form-data
: https://developers.facebook.com/docs/graph-api/reference/page/photos/#Creating
示例: http://www. devils-heaven.com/facebook-javascript-sdk-photo-upload-with-formdata/
这篇关于从本地存储上传Facebook图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!