How to store a Facebook user’s friends list in MySQL using PHP?
I am able to get and print the user’s friends list using the PHP code below?
//get friends list
$friends_list = file_get_contents('https://graph.facebook.com/me/friends?access_token=' . $atoken );
$friends_list_array = json_decode($friends_list,true);
//convert so that store in mysql
$my_friends = implode("," , $friends_list_array['data']);
echo "</br> my friends" . $my_friends;
//result my friendsArray,Array,Array,Array,Array,Array,Array,Array.....
How can I store a friends list in MySQL?
the
friendsconnection will return the friend’snameandidencapsulated in adataarray. So you need to go one step down the array and collect the ids beforeimplode: