猿问

反应| Facebook JS API:尝试将多张图片上传到我的页面供稿时,错误代码为100

在第一个功能中,我将多个图像上载到page-id/photos这些图像的所有ID并收到肯定的响应。


但是下一部分是我遇到的问题;我现在正尝试在Facebook页面时间轴上创建包含多张图片的帖子。但是,我收到一个奇怪的错误响应,声称我已经上传了图像。


我什至在使用Open Graph Explorer的文档中都遵循了Facebook的示例,但这只是返回了另一个错误


发送图像的功能:

(没有问题的作品)


sendFacebookImagePost(page) {

    const attached_media = []

    for(let i = 0; i < this.state.upload_imgsrc.length; i++) {

        let reader = new FileReader();

        reader.onload = (e) => {

            let arrayBuffer = e.target.result;

            let blob = new Blob([arrayBuffer], { type: this.state.upload_imgsrc[i].type });

            let data = new FormData()

            data.append("source", blob)

            data.append("message", this.state.fb_message)

            data.append("no_story", true)

            data.append("published", true)


            axios({

                method: "post",

                url: "https://graph.facebook.com/" + page.id + "/photos?access_token=" + page.accessToken,

                data: data

            })

            .then(response => {

                attached_media.push({media_fbid: response.data.id})

                if (attached_media.length === this.state.upload_imgsrc.length) {

                    this.sendFacebookPost(page, attached_media)

                }

            })

            .catch(error => {

                console.log(error);

            })

        }

        reader.readAsArrayBuffer(this.state.upload_imgsrc[i]);

    }

}


蝴蝶不菲
浏览 183回答 1
1回答

白衣非少年

发生问题的部分是我在图片中添加了以下内容:data.append("published", true)。显然,要在多张照片帖子中使用的图像必须先设置为,published: false然后才能在帖子中使用。否则,Facebook将其视为已上传。
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答