PHP Facebook API -访问对象数组项目


PHP Facebook API - Access Object Array Item

我有一个对象数组(显示在底部),可以通过以下操作访问数据:

echo $MyVariable->id;
echo $MyVariable->type;

等等。但是,我不能通过以下方式访问[count]项:

echo $MyVariable->id;

有人知道为什么吗?Count似乎还有别的意思,也许是Count ?

  stdClass Object (
[id] => 573948779291487 
[from] => stdClass Object (
[category] => Bar 
[category_list] => Array (
[0] => stdClass Object (
[id] => 218693881483234 
[name] => Pub 
) 
[1] => stdClass Object (
[id] => 164049010316507 
[name] => Gastropub 
) ) 
[name] => The Melbourne Arms 
[id] => 533195070033525 
) 
[name] => The Melbourne Arms Gallery 
[location] => The Melbourne Arms 
[place] => stdClass Object (
[id] => 533195070033525 
[name] => The Melbourne Arms 
[location] => stdClass Object (
[street] => Main Street 
[city] => Melbourne 
[country] => United Kingdom 
[zip] => YO42 4QJ 
[latitude] => 53.8872441 
[longitude] => -0.8554097 
) ) 
[link] => http://www.facebook.com/album.php?fbid=573948779291487&id=533195070033525&aid=1073741825 
[cover_photo] => 573948812624817 
[count] => 28 
[type] => normal 
[created_time] => 2013-03-13T22:22:45+0000 
[updated_time] => 2013-03-13T22:34:40+0000 
[can_upload] => 
[likes] => stdClass Object (
[data] => Array (
[0] => stdClass Object (
[id] => 1361671776 
[name] => Lesley Maiden 
) 
[1] => stdClass Object (
[id] => 518580863 
[name] => Diane Maiden 
) 
[2] => stdClass Object (
[id] => 1254875611 
[name] => Vanessa Wilson 
) 
[3] => stdClass Object (
[id] => 533195070033525 
[name] => The Melbourne Arms 
) 
[4] => stdClass Object (
[id] => 100001664649752 
[name] => Bowen Lee 
) ) 
[paging] => stdClass Object (
[next] => https://graph.facebook.com/573948779291487/likes?limit=25&offset=25&__after_id=100001664649752 
) ) ) 1

尝试用不同的方式处理数据

$data  = file_get_contents("https://graph.facebook.com/573948779291487");
$data = json_decode($data, true);
echo $data['count'];