Facebook Error 100: You cannot specify a scheduled publish time on a published post

不羁的心 提交于 2019-12-21 16:49:45

问题


I just had to do this. Absolutely every question I looked up questions regarding this issue but none of their answers helped me solve it.

I am trying to post on my Facebook page.

Here is the issue:

Error: "(#100) You cannot specify a scheduled publish time on a published post"

Code:

FB.api(
    "/100177680105780/feed",
    "POST",
    {

        "message": "This is a test message",
        "scheduled_publish_time": Math.round(new Date().getTime() / 1000) + 120

    },
    function (response) {
        console.log(response);
        if (response && !response.error) {
            /* handle the result */
        }
    });

I have no idea why this is giving me this error. It doesn't work even if I add the "object":{} around the content of the post. I tried changing the UNIX time stamp, I tried changing the message, I tried setting "published": false and no luck.

Any guidance would be amazing.


回答1:


"published": false should be set in order to publish the scheduled posts. If you carefully see the error after you set this parameter, it says:

(#200) Unpublished posts must be posted to a page as the page itself.

The scheduled posts can be published only using the page access token - logical enough since those who have the permission to manage the pages can schedule the post.

Also, with your code (where you are using a normal user access token), the post is published as yourself not on behalf of the page. And these posts are visible on the side bar not on the main wall- that's not what you are looking for right? :)

So, use the page access token. To get the page access token, get the new user token first with manage_pages permission and make the call-

\GET /{page-id}?fields=access_token

Use this token and make the call to schedule the post-

FB.api(
"/{page-id}/feed",
"POST",
{
    "message": "This is a test message",
    "scheduled_publish_time": Math.round(new Date().getTime() / 1000) + 120,
    "published": false,
    "access_token": "{page-access-token}"
},
function (response) {
    console.log(response);
    if (response && !response.error) {
        /* handle the result */
    }
});

I'm not sure about what exactly your application does, but if getting a never-expiring page access token helps you you can see my answer here for the same.

Hope that helps!

Edit:

As @Tobi has mentioned, also make sure UNIX timestamp is between 10 minutes and 6 months from the time of publish. Since you are using 2 minutes, that may also create problem.




回答2:


The docs at https://developers.facebook.com/docs/graph-api/common-scenarios#scheduledposts are saying that scheduled_publish_time

should be a UNIX timestamp that is the between 10 minutes and 6 months from the time of publish

As you're only adding 120 seconds, I guess this could be the reason why it doesn't work. Try adding at least 600 seconds and test it again.

https://developers.facebook.com/docs/graph-api/reference/page/feed/#pubfields says this as well.

As @Sahil mentioned, you also need to use a Page Access Token, which needs to be set manually as he described.



来源:https://stackoverflow.com/questions/23002547/facebook-error-100-you-cannot-specify-a-scheduled-publish-time-on-a-published-p

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