0
    $queries = array(
        array('method' => 'GET', 'relative_url' => '/'.$user),
        array('method' => 'GET', 'relative_url' => '/'.$user.'/home?limit=50'),
        array('method' => 'GET', 'relative_url' => '/'.$user.'/friends'),
        array('method' => 'GET', 'relative_url' => '/'.$user.'/photos?limit=6'),
        );

    // POST your queries to the batch endpoint on the graph.
    try{
        $batchResponse = $facebook->api('?batch='.json_encode($queries), 'POST');
    }catch(Exception $o){
        error_log($o);
    }

    //Return values are indexed in order of the original array, content is in ['body'] as a JSON
    //string. Decode for use as a PHP array.
    $user_info      = json_decode($batchResponse[0]['body'], TRUE);
    $feed           = json_decode($batchResponse[1]['body'], TRUE);
    $friends_list   = json_decode($batchResponse[2]['body'], TRUE);

我已将代码编辑为

$queries = array('method' => 'GET', 'relative_url' => '/'.$user);

try{
    $batchResponse = $facebook->api('?batch='.json_encode($queries), 'POST');
}catch(Exception $o){
    error_log($o);
}

$user_info      = json_decode($batchResponse['body'], TRUE);

但是当我回显 $user_info 时它不再正常工作并且没有价值

我做错了什么?

4

2 回答 2

2

您更改了嵌套数组结构。我认为你需要:

$queries = array(
    array('method' => 'GET', 'relative_url' => '/'.$user)
    );

代替

$queries = array('method' => 'GET', 'relative_url' => '/'.$user);
于 2012-12-13T17:19:04.547 回答
0

最后一行:

     array('method' => 'GET', 'relative_url' => '/'.$user.'/photos?limit=6'),

最后不应该昏迷

     array('method' => 'GET', 'relative_url' => '/'.$user.'/photos?limit=6')
于 2012-12-13T17:19:32.700 回答