简体   繁体   English

反应| Facebook JS API:尝试将多个图像上传到我的页面Feed时出现错误代码100

[英]React | Facebook JS API : Error code 100 when trying to upload multiple images to my page feed

In a first function, I upload multiple images to page-id/photos and receive a positive response with all the ids of these images. 在第一个功能中,我将多个图像上传到page-id/photos并使用这些图像的所有ID获得肯定响应。

The next part however is where I'm stuck; 然而,下一部分是我被困住的地方; I am now trying to create a post with multiple images to my Facebook page timeline. 我现在正试图在我的Facebook页面时间轴上创建一个包含多个图像的帖子。 However, I'm getting a weird error response claiming that I already have uploaded my images. 但是,我得到一个奇怪的错误响应声称我已经上传了我的图像。

I've even followed Facebook's own example from their documentation using Open Graph Explorer, but that just returns another error 我甚至使用Open Graph Explorer从他们的文档中跟踪Facebook自己的例子,但这只会返回另一个错误

Function to send image: 发送图片的功能:

(works without a problem) (没有问题)

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

Function to send post: 发帖功能:

(Here is where the error happens) (这是错误发生的地方)

sendFacebookPost(page, attached_media) {
    let data = { 
            message: this.state.fb_message, 
            link: this.state.fb_link,
            attached_media: attached_media
            // this is what attached_media returns:
            // [
            //     {media_fbid: response.data.id},
            //     {media_fbid: response.data.id}
            // ]
        }
    axios({
        method: "post",
        url: "https://graph.facebook.com/" + page.id + "/feed?access_token=" + page.accessToken,
        data: data
    })
    .then( () => this.setState({fb_successMessage: "Post successful!", fb_errorMessage: ""}) )
    .catch(error => {
        console.log(error);
    })
}

Error code 错误代码

error: {
    code: 100
    error_subcode: 1366051
    error_user_msg: "These photos were already posted."
    error_user_title: "Already Posted"
    fbtrace_id: "Cl9TUTntOZK"
    is_transient: false
    message: "Invalid parameter"
    type: "OAuthException"
}

My try on Open Graph Explorer 我尝试使用Open Graph Explorer

Problem solved. 问题解决了。
The part that went wrong is where I add the following to my image post: 出错的部分是我在图片帖子中添加以下内容的地方:
data.append("published", true) . data.append("published", true)

Apparently, images you want to use in a multi photo post have to be set to published: false before they can be used in a post. 显然,要在多张照片中使用的图像必须设置为published: false然后才能在帖子中使用它们。 Otherwise, Facebook sees this as already uploaded. 否则,Facebook认为这已经上传。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Facebook API返回错误代码100 - Facebook api return error code 100 API错误代码:100 facebook OpenGraph - API Error code: 100 facebook OpenGraph 尝试在Facebook json feed中使用backbone.js时出现语法错误 - syntax error when trying to use backbone.js with Facebook json feed Facebook 页面视频上传 API 权限错误 - Facebook Page Video Upload API Permission Error 尝试将图像上传到 Firebase 存储时出错 - Error when trying to upload images to Firebase storage 在React Js中处理多个上传图像+将其发送到服务器 - Handling Multiple Upload Images in React Js + Send it to Server Angular observable 在尝试获取多个图像时抛出状态代码为 200 的错误 - Angular observable throws error with status code 200 when trying to get multiple images Facebook Marketing API | 节点js | “消息”:“不支持的帖子请求”。,“类型”:“ GraphMethodException”,“代码”:100 - Facebook Marketing API | node js | “message”:“Unsupported post request.”,“type”:“GraphMethodException”,“code”:100 带有多个图像的 Facebook 广告和 Facebook 营销 API - Facebook Ad with multiple images with Facebook marketing API Facebook API错误100-无效链接 - Facebook API Error 100 - invalid link
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM