$total_posts = array();
$posts_response = $posts_request->getGraphEdge();
if($fb->next($posts_response)) {
$response_array = $posts_response->asArray();
$total_posts = array_merge($total_posts, $response_array);
while ($posts_response = $fb->next($posts_response)) {
$response_array = $posts_response->asArray();
$total_posts = array_merge($total_posts, $response_array);
}
//print_r($total_posts);
/*foreach ($total_posts as $results) {
echo $results; // prints the array in the following format: "[id] => 1 [name] => host1plus"
echo $results['id'] .'<br>'; // prints only the ID
echo $results['story'] .'<br>'; // prints only the Name
}*/
foreach ($total_posts as $key ) {
echo $key['message'].'<br>';
}
} else {
$posts_response = $posts_request->getGraphEdge()->asArray();
print_r($posts_response);
}
// storing in the database.
$my_array = serialize($total_posts);
$sql = "INSERT INTO users1 (name, token, message) VALUES ('$name', '$accessToken', '$my_array')";
if ($db->query($sql) === TRUE) {
echo "New record created successfully !!";
} else {
echo "Error: " . $sql . "<br>" . $db->error;
}
$db->close();