I am Creating A facebook that Retrieves 10 Random friends.But I need some code to Retrieve Top friends using comment and like ativity.I used Following code but i get below error
Invalid argument supplied for foreach()
below is the code i tried so far.
$statuses = $facebook->api('/me/statuses');
foreach($statuses['data'] as $status){
// processing likes array for calculating fanbase.
foreach($status['likes']['data'] as $likesData){
$frid = $likesData['id'];
$frname = $likesData['name'];
$friendArray[$frid] = $frname;
}
foreach($status['comments']['data'] as $comArray){
// processing comments array for calculating fanbase
$frid = $comArray['from']['id'];
$frname = $comArray['from']['name'];
}
That error message generally happens when your array variable is not set. If you could add line numbers to your code and give the full error message (including line number) it might help.
Can you show a print_r of $statuses[‘data’]?