Dear friends,
I'm trying to get our notes in a Facebook page and store in in our database so that can have the source of these notes online. Also, we want to use it to construct our web page.
You know with Graph API we can get the notes with title, content, published date etc. But since Graph API is not working fast and I cannot do it with FQL (Facebook Query Language) so, I though I needed to store the information coming from Graph API in an array into a database.
I did lots of search on Google, I found best way to do it first serialize, store and then show it unserializing. I'm only able to serilize the array now. When it comes to inserting it into database, it fails.
In the below code, I get the last 25 notes with Graph API (not shown) in $notes array, then I take some of the elements and put them into $needed_fields array. And the query comes after I serialize it.
I think the problem is in the $query. Because I got an error: Column count doesn't match value count at row 1
for($i=0;$i<25;$i++)
{
$each_note = $notes['data'][$i];
$needed_fields = array (
'subject' => $each_note['subject'],
'message' => $each_note['message'],
'icon' => $each_note['icon'],
'created_time' => $each_note['created_time'],
'updated_time' => $each_note['updated_time'],
);
foreach($needed_fields as $k => $v) {
$needed_fields[$k] = mysql_real_escape_string($v);
}
$serialized_notes = serialize($needed_fields);
$query = "INSERT INTO notes
(subject, message, icon, created_time, updated_time) VALUES
('$serialized_notes')";
mysql_query($query) or die(mysql_error());
}
Best wishes,
Gungor