phpfacebook-graph-apiforeach

foreach on status comments from facebook sdk


Can someone tell me what seems to be the issue with this?

<?php 
    $increment = 0;
    foreach($status['comments']['data'] as $user_status_comments_value) {
?>

I'm getting a warning:

Warning: Invalid argument supplied for foreach() in /var/www/social/facebook/social/examples/dev.php on line 179


Solution

  • You would need to rearrange your code a bit

    foreach($status['data'] as $statusupdate) {
        $user_status_comments_value = $statusupdate["comments"]
        //Dont forget you would still need to loop through each set of comments
        foreach($user_status_comments_value as $comment) {
            ///$comment["data"] contains a comment
            ...
        }
    }