Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 914
Tiffany Lowe Avatar asked Apr 11 '14 02:04

Tiffany Lowe


2 Answers

"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.

like image 197
Sahil Mittal Avatar answered Oct 02 '22 14:10

Sahil Mittal


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.

like image 31
Tobi Avatar answered Oct 02 '22 13:10

Tobi