0
嘿,我試圖讓所有喜歡的壁帖在PHP中。陣列框架是這樣的:通過Facebook api「喜歡」循環播放
Array (
[data] => Array (
[0] => Array (
[id] => XXXXXXXX_XXXXXXXXXXX
[from] => Array (
[name] => Bob Barker
[id] => XXXXXXXXXXX
)
[message] => This is a message here!!!
[story] => We shared a message with others
[story_tags] => Array (
[0] => Array (
[0] => Array (
[id] => XXXXXXXXXX
[name] => Bob Barker
[offset] => 0
[length] => 11
[type] => user
)
)
[19] => Array (
[0] => Array (
[id] => XXXXXXXXXXXXXXXXXXXXXXX
[name] => NAME
[offset] => 19
[length] => 5
[type] => page
)
)
)
[picture] => [removed]
[link] => [removed]
[name] => Timeline Photos
[caption] => This is just a caption for the post here
[properties] => Array (
[0] => Array (
[name] => By
[text] => NAME
[href] => [removed]
)
)
[icon] => https://fbstatic-a.akamaihd.net/rsrc.php/v2/yD/r/aS8ecmYRys0.gif
[actions] => Array (
[0] => Array (
[name] => Like
[link] => [removed]
)
)
[privacy] => Array (
[value] =>
)
[type] => photo
[status_type] => shared_story
[object_id] => XXXXXXXXXXXXXXXX
[application] => Array (
[name] => Photos
[id] => XXXXXXXXXX
)
[created_time] => 2014-02-12T21:33:17+0000
[updated_time] => 2014-02-12T21:33:17+0000
[likes] => Array (
[data] => Array (
[0] => Array (
[id] => XXXXXXXXXXXX
[name] => John Doe
)
[1] => Array (
[id] => XXXXXXXXXXXX
[name] => Steve Doe
)
)
[paging] => Array (
[cursors] => Array (
[after] => XXXXXXXXXXXXXXXX
[before] => XXXXXXXXXXXX==
)
)
)
)
我當前的PHP代碼:
$feed = $facebook->api('/me/home'); //This is the array above
foreach($feed['data'] as $post) {
$story = (isset($post['story']) ? $post['story'] : null);
$id = (isset($post['id']) ? $post['id'] : null);
$name = (isset($post['name']) ? $post['name'] : null);
$message = (isset($post['message']) ? $post['message'] : null);
$post_link = (isset($post['actions'][0]['link']) ? $post['actions'][0]['link'] : null);
$picture = (isset($post['picture']) ? $post['picture'] : null);
foreach($post['likes'] as $liked) {
echo $post['id'];
}
echo $name . ' ' . $story . ' it was: ' . $message . ' and ' . $post_link . ' and <img src="' . $picture . '" /><br />';
echo '=======================================================================================================';
}
的
foreach($post['likes'] as $liked) {
echo $post['id'];
}
似乎並不奏效原樣。我爲了讓它遍歷數組中所有「喜歡」的帖子而丟失了什麼?