I want to access the Facebook Graph API and get JSON responses like this:
{
"data": [
{
"name": "Coldplay",
"category": "Musician/band",
"id": "15253175252",
"created_time": "2012-01-27T22:51:44+0000"
},
{
"name": "R.E.M.",
"category": "Musician/band",
"id": "8759772983",
"created_time": "2012-01-27T22:51:43+0000"
}
],
"paging": {
"next": "https://graph.facebook.com/1000032123447/music?format=json&limit=5000&offset=5000&__after_id=8123918"
}
}
Now I want to save the name, the category and id into my rails database. I have got a table with the same columns.
What is the easiest way to save this response into the matching columns of the database? Or is there a better solution, i.e. just saving the whole json object into the database and read it later on in the code again?
If you have time, please provide a coding example for the javascript/jQuery (ajax maybe) and ruby code. Thank you so much!