2014-01-09 92 views
0

香港專業教育學院設置所需的權限,並得到了路徑,即我/照片這顯示:如何使用Facebook的API,讓你自己的Facebook圖片

{ 
    "data": [ 
    { 
     "id": "78768", 
     "from": { 
     "name": "Dai beckham", 
     "id": "135656456" 
     }, 
     "picture": "link here", 
     "source": "link here", 
     "height": 540, 
     "width": 720, 
     "images": [ 
     { 
      "height": 720, 
      "width": 960, 
      "source": "link here" 
     }, 

然後我嘗試呼應像echo $user_graph['data']['source'];成像路徑,但IM得到一個錯誤

「通知:未定義指數:源答:第12行的文件name.php」

我不知道在哪裏我去錯了。提前致謝。

+0

這看起來像'json',你是否先將它轉換爲數組? 'json_decode()' – naththedeveloper

+0

如果其中一個答案對您有幫助,請記住通過單擊向上和向下箭頭下方的複選標記來接受答案。 – naththedeveloper

回答

1

您需要將響應轉換爲數組,然後才能像這樣訪問它。

當前格式爲JSON格式。您可以使用本地json_decode()函數爲您進行轉換。

$array = json_decode($response, true); 

$source = $array['data']['source']; 
0
$array = json_decode($response, true); //it will provide array 
$source = $array['data']['source']; and access it now 
相關問題