Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
227 views
Welcome To Ask or Share your Answers For Others

1 Answer

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/


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...