How to post updates on a Facebook page automatically at a given time? using android

I need to automatically post to the page when the user has set a specific scheduled time. I tried using Graph api with the request below:

    Bundle params1 = new Bundle();
    params1.putString("message", "This is a system generated post");
    params1.putString("scheduled_publish_time",(date.getTime()+(1000*60*30))""); //for current time to next 30 min
    params1.putBoolean("published", false);
    new GraphRequest(
            accessToken,
            "/850285671748182/feed",               
            params1,
            HttpMethod.POST,
            new GraphRequest.Callback() {
                public void onCompleted(GraphResponse response) {
        /* handle the result */
                    Log.d("Response-auto", "DATA" + response);

                }
            }
    ).executeAsync();

But he gives below answer.

{"error": {"message": "(#100) The specified scheduled publish time is invalid.",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "HcuHy8cusGC"}}
+4
source share
1 answer

You must install Unix TimeStamp in seconds. Add a way to convert your current milliseconds to Unix Second

Long unixsecond=Calendar.getInstance().getTimeInMillis()/1000L;
+2
source

Source: https://habr.com/ru/post/1670392/


All Articles