我從Facebook(下面的代碼片段)的JSON提要中加載。從json結構訪問數據
{
"data": [
{
"id": "115972604762",
"from": {
"name": "Title Here",
"category": "Musicians",
"id": "20274769762"
},
"name": "It was an amazing gig!!",
"picture": "http://photos-h.ak.fbcdn.net/hphotos-ak-snc1/hs196.snc1/6616_115972604762_20274769762_2185148_6347071_s.jpg",
"source": "http://sphotos.ak.fbcdn.net/hphotos-ak-snc1/hs196.snc1/6616_115972604762_20274769762_2185148_6347071_n.jpg",
"height": 453,
"width": 604,
"images": [
{
我加載它使用$data['pics'] = json_decode(file_get_contents('https://graph.facebook.com/'. $id .'/photos'));
我怎麼會去echo'ing出從 - >名稱值,以獲得「標題下面的價值?
我得到一個PHP錯誤。我試圖print_r並得到這個:http://gist.github.com/632887 – Plasticated 2010-10-18 19:39:47
啊,它的解碼就是因爲它的對象。試試:echo $ array-> data [0] - > from-> name; – 2010-10-18 19:51:23
謝謝!對不起,我沒有意識到對象會改變數據的訪問方式。 – Plasticated 2010-10-18 19:52:56