从本地存储上传Facebook图像 [英] Facebook image upload from local storage

查看:45
本文介绍了从本地存储上传Facebook图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆