Hi I am trying to do the same thing. I would like to save the Facebook user timeline details OR messages in MySQL database.
Structure of the array is like

Array ( [0] => Array (
[story] => Anupam Jamatia shared The Frustrated Engineer's video.
[created_time] => DateTime Object
( [date] => 2016-02-08 01:18:59.000000
[timezone_type] => 1
[timezone] => +00:00 )
[id] => 10154521329397892_10154534663442892 )
[1] => Array (
[story] => Anupam Jamatia shared 24 Ghanta's post.
[created_time] => DateTime Object
( [date] => 2016-02-07 15:03:28.000000
[timezone_type] => 1
[timezone] => +00:00 )
[id] => 10154521329397892_10154533473037892 )
[2] => Array (
[story] => Anupam Jamatia shared a link.
[created_time] => DateTime Object
( [date] => 2016-02-07 14:54:39.000000
[timezone_type] => 1
[timezone] => +00:00 )
[id] => 10154521329397892_10154533459592892 )
[3] => Array (
[story] => Anupam Jamatia shared a link.
[created_time] => DateTime Object
( [date] => 2016-02-05 01:31:52.000000
[timezone_type] => 1
[timezone] => +00:00 )
[id] => 10154521329397892_10154527172812892 )
)

actual facebook timeline details are visible in screen total posts are like this http://screenshot.co/#!/2dcbee03ff , if I want to see the 'messages' only I can see in the screen like http://screenshot.co/#!/635a038dd5 but not able to store in MySQL database. I tried with the following Code snippet but I am not getting expected result. I am getting "Array" in the message field http://screenshot.co/#!/9385792e8a . Please help me how to store all messages in single row for single user.

Code Snippets:

$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 $key ) {
echo $key['message'].'<br>';
}
} else {
$posts_response = $posts_request->getGraphEdge()->asArray();
print_r($posts_response);
}
// storing in the database.
$sql = "INSERT INTO users1 (name, token, message)
VALUES ('{$name}', '{$accessToken}', '{$total_posts}')";
if ($db->query($sql) === TRUE) {
echo "New record created successfully !!";
} else {
echo "Error: " . $sql . "<br>" . $db->error;
}
$db->close();

    Perhaps a case for [man]serialize[/man]?

      I tried with serialize also. But not able to store it. any clue please

        What exactly did you try concerning serialisation?

          $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] =&gt; 1 [name] =&gt; 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();

            What error to you get? Is the "message" column large enough (and of the correct type) to store the serialized string? Also, you'll likely need to escape it before using it in your SQL (or better yet use prepared statements and bound parameters so you don't have to worry about it).

              I am not getting error neither it reflects on database. I kept the "message" column type as TEXT. I am not getting your point to "escape it before using SQL". Can you give some example please?

                [man]PDO.prepare[/man]
                [man]PDO.quote[/man]

                  Write a Reply...