Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Facebook图形api/me/photos问题_Php_Facebook_Facebook Graph Api - Fatal编程技术网

Php Facebook图形api/me/photos问题

Php Facebook图形api/me/photos问题,php,facebook,facebook-graph-api,Php,Facebook,Facebook Graph Api,我目前在不同的facebook页面上发布图片和URL,但我使用了很多电话来做同样的事情 与此相反,我尝试处理批处理请求以节省执行时间,但我遇到了一个问题 在打很多电话时,我使用以下方法: $urlLink = '/' . $pageId . '/photos'; $args = array( 'url' => $this->image_url, 'message' => $this->m

我目前在不同的facebook页面上发布图片和URL,但我使用了很多电话来做同样的事情

与此相反,我尝试处理批处理请求以节省执行时间,但我遇到了一个问题

在打很多电话时,我使用以下方法:

$urlLink = '/' . $pageId . '/photos';

$args = array(
    'url'                    => $this->image_url,
    'message'                => $this->message,
    'published'              => false,
    'scheduled_publish_time' => strtotime($this->programmed_dt),
);
$res = $this->fb->api($urlLink, 'POST', $args);
它很好用

对于批处理请求,我尝试了:

$urlLink = '/' . $facebookPage['id'] . '/photos';
$args['access_token'] = $facebookPage['access_token'];
$queries[] = array('method'       => 'POST',
                   'relative_url' => $urlLink,
                   'body'         => $args,
                   'url' => $this->image_url
);

$res = $this->fb->api('?batch=' . json_encode($queries), 'POST');
我得到的答复是:

{"error":{"message":"(#324) Requires upload file","type":"OAuthException","code":324}}
我试图改变名称字段与所有的可能性发送图像链接,但没有成功

对于使用图像URL的批处理请求有什么想法吗

根据我的假设,构成请求的代码没有正确的语法

在我看来,应该是这样的:

$args['access_token'] = $facebookPage['access_token'];
$queries[] = array('method'       => 'POST',
                   'relative_url' => $urlLink,
                   'body'         => 'url=' . $this->image_url
);

$res = $this->fb->api('/?batch=' . json_encode($queries) . '&access_token=' . $args['access_token'], 'GET');

我可以在你的代码中看到一切正常,除了这个-

在发布图像之前,您应该将上传支持设置为
true

$this->fb->setFileUploadSupport(true);
有关更多详细信息,请查看以下答案:


您将每个页面令牌发送到哪里?因为我们有主令牌(用户),但为了能够发布到页面,我还需要发送页面令牌(从/me/accounts获得)。您可以向批处理的每个请求添加访问令牌,请参见需要将其添加到body参数。“外部”访问令牌就是回退访问令牌。我稍后会尝试,我会告诉你一些消息。谢谢。仍然存在“(#324)需要上传文件”问题。我们可以批量发送图像URL而不是上传文件吗?我知道没有批次,是的,这是可能的。