/ me / photos上的Facebook批量请求不会安排我的帖子

时间:2014-07-06 00:05:53

标签: php facebook api facebook-graph-api

我正在使用没有批量请求的facebook图表api来安排图片的帖子到我的页面。

现在我正在尝试处理批处理请求,但是我遇到了问题,即使我设置参数来延迟照片,照片也会立即发布。

示例:

$args = array(
    'message' => $this->message,
);
$args['published'] = false;
$args['scheduled_publish_time'] = strtotime($this->programmed_dt);

$appsecretProof = hash_hmac('sha256', $facebookPage['access_token'], self::APP_SECRET);

$queries[] = array('method'         => 'POST',
    'relative_url'   => urlencode('/' . $facebookPage['id'] . '/photos?access_token=' . $facebookPage['access_token'] . '&appsecret_proof=' . $appsecretProof),
    'body'           => $args,
    'attached_files' => 'file1',
);
$params['file1'] = '@' . realpath('images/' . $timestamp . '.jpg');
$urlPost = '?batch=' . json_encode($queries) . '&access_token=' . self::ACCESS_TOKEN;

$res = $this->fb->api($urlPost, 'POST', $params);

我对帖子ID有回复,但照片信息没有安排......你看错了吗?

感谢。

1 个答案:

答案 0 :(得分:0)

找到:

published和scheduled_publish_time应该传递给relative_url

$relativeUrl = '/' . $facebookPage['id'] . '/photos?published=' . (string) $args['published'];
$relativeUrl .= $args['published'] ? '' : '&scheduled_publish_time=' . $args['scheduled_publish_time'] . '&access_token=' . $facebookPage['access_token'] . '&appsecret_proof=' . $appsecretProof;