0

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 found.

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?

1 Answer 1

1
$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;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.