FB批量请求:获取托管页面的Profil图像

时间:2013-04-08 21:35:25

标签: php facebook facebook-graph-api batch-file fbconnect

您好,我试图获取我管理的所有页面的个人资料图片。 我试过这样的事情:

  

//我的循环:

$request[] = array(
                 'method' => 'POST',
                 'relative_url' => '/'.$account->id.'/?fields=picture.type(large)&access_token='.$account->access_token.''
             );

然后:

  $batchResponse = $this->facebook->api('?batch='.json_encode($request),'POST',array('access_token' => $this->facebook->getAccessToken()));

没有成功:/

我还尝试在body标签中设置页面的access_token:

    $request[] = array(
       'method' => 'POST',
       'relative_url' => '/'.$account->id.'/?fields=picture.type(large)'
       'body' => '&access_token='.$account->access_token.''
    ;

1 个答案:

答案 0 :(得分:1)

你的PHP script should have you login。如果登录成功,SDK将为您管理access_token。

然后发出这一个请求:

$result = $this->facebook->api('/me/accounts?fields=name,picture.type(large)', 'GET');

如果您不想进行身份验证,则可以传递一组ID:

$page_ids = array( _PAGE_ID_1, _PAGE_ID_2, ...);
$result = $this->facebook->api('/?ids=' . implode(',',$page_ids) . '&fields=name,picture.type(large)', 'GET');

对于这些查询,您获取数据,因此您应该使用GET请求。在Facebook API中,POST请求仅在您向Facebook发送数据时使用。