如何在给定的预定时间内自动在Facebook页面上发布更新?使用android

San*_*ani 5 android facebook facebook-graph-api android-facebook facebook-share

当用户设置特定的预定时间时,我需要在页面上自动发布.我尝试使用Graph api和以下请求:

    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();
Run Code Online (Sandbox Code Playgroud)

但它给出了以下回应.

{"error": {"message": "(#100) The specified scheduled publish time is invalid.",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "HcuHy8cusGC"}}
Run Code Online (Sandbox Code Playgroud)

San*_*ani 3

您必须以秒为单位设置 Unix 时间戳。以下方法将当前毫秒转换为 Unix 秒

Long unixsecond=Calendar.getInstance().getTimeInMillis()/1000L;
Run Code Online (Sandbox Code Playgroud)