2012-11-28 64 views
1

如何显示数据 - >名称?Facebook JSON数组

{ 
    "data": [ 
     { 
     "name": "Aasdada", 
     "category": "asdasd", 
     "id": "2342342342", 
     "created_time": "2012-11-28T03:56:00+0000" 
     } 
    ], 
    "paging": { 
     "next": "https://graph.facebook.com/&limit=5000&offset=5000&__after_id=12312" 
    } 
} 

我试过,但没有出来:

$user = json_decode(file_get_contents($graph_url), true); 
echo("Hello " . $user->data->name); 

//also tried this 
echo("Hello " . $user[data]); //did not echo anything 
echo("Hello " . $user->data[0]->name); //did not echo anything 

$user->data[0]['name'] //still no luck 

可能是什么问题呢? 反正我的代码可以处理不在数组中的数据。

我只是试图让一个简单的,如果用户喜欢的页面或不。 如果数据没有内容,则意味着用户不喜欢该页面。 如果它有数据,则表示用户已经喜欢该页面。

- 编辑 -

所以尝试了这一点:

array(2) { ["data"]=> array(1) { [0]=> array(4) { ["name"]=> string(28) "Aasdda" ["category"]=> string(5) "asdad" ["id"]=> string(15) "3123123123" ["created_time"]=> string(24) "2012-11-28T03:56:00+0000" } } ["paging"]=> array(1) { ["next"]=> string(245) "https://graph.facebook.com/100023123123" } } 

回答

0

尝试:

$user->data[0]['name'] 
+0

你好没有任何回音。 – madziikoy

+0

尝试第二个。 – JPR

+0

第二个仍然没有运气的人。我编辑了我的问题。 :) – madziikoy