开发者

PHP JSON Insert in the Database for each found Data

I am using Facebook API to get the Facebook Pages a user administers on Facebook.

Have a look here:

https://graph.facebook.com/100000901920184/accounts/&access_token=217662841620006|20de00ae16afeb68d32319d8.1-100000901920184|BCz2UJbFylKY_eG969GlBR4loqo

What I need to do is to insert in the Database EACH Facebook Page that is fo开发者_StackOverflow社区und.

The DB will be structured in this way:

-ID (autoincrement)
-PageName (the name of the Page)
-PageID (the ID of the page 
-access_token (the Access Token of the Page)
-OwnerID (this is the user ID I will grab from another function I have)

So now do not mind this is for Facebook API. Just think you have those data to grab and you need to insert in the DB the above values for EACH Fan page.

This can be done with JSON but I really do not know how to grab that data, organize the Data and Insert it in the DB for Each Page.

Can you help me please?


$file = json_decode(file_get_contents('https://graph.facebook.com/100000901920184/accounts/&access_token=217662841620006%7C20de00ae16afeb68d32319d8.1-100000901920184%7CBCz2UJbFylKY_eG969GlBR4loqo'));

foreach($file->data as $row){
    $query = "INSERT INTO `table`(`ID`, `PageName`, `PageID`, `access_token`, `OwnerID`) VALUES (0, '".$row->name."', '".$row->id."', '".$row->access_token."', '".getOwnerIdFunction()."')";
    // run Query;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜