Facebook image upload from local storage

ぃ、小莉子 提交于 2019-12-13 08:59:19

问题


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); }

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

Error


回答1:


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

Example: http://www.devils-heaven.com/facebook-javascript-sdk-photo-upload-with-formdata/



来源:https://stackoverflow.com/questions/48710323/facebook-image-upload-from-local-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!