2012-12-13 31 views
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); 

我已編輯的代碼是後,我已經編輯我的PHP代碼,它不能正常工作

$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

我做了什麼錯?

+2

昏迷「無法正常工作不再「 - 根本沒有幫助 – KevinDTimm

+0

錯誤是什麼由FB API調用返回? – jamis0n

+1

如果確實有效並且現在不行,請撤消更改。 – GolezTrol

回答

2

您更改了嵌套數組結構。我想你需要:

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

,而不是

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

最後一行:

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

不應該有在年底

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

1)您正在查看未修改的代碼,以及2)數組最後一個元素後面的逗號不會導致錯誤。 – Crontab

+0

它使用了你。 im old school – MAXIM

+0

10年PHP開發 - 跟上你的手藝。 ;) – Crontab

相關問題