Hello Reader's if you are looking to develop a web app which gets the facebook user profile details then by using PHP you can do this. Facebook gives us the public details of any user like: photo, cover location and birthdays. To use this you need to do some work on Graph API by Facebook. So lets get started working on it.
Step1: First create login in https://developers.facebook.com/ as a developer
Step2: Create new app fill all its details required and make it live.
Step3. Create a new function in your controller name it to fb(). Its code will go like this:-
$curl = curl_init();
$token = 'YOUR_FB_TOKEN';
// Set some options - we are passing in a useragent too here
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => 'https://graph.facebook.com/'.$userid.'?fields=bio,education,email,gender,hometown,cover,name&access_token='.$token,
CURLOPT_USERAGENT => 'snooptravel via curl'
// Send the request & save response to $resp
$resp = curl_exec($curl);
$user_fb = json_decode($resp, 1);
In the code, the request you sent is made by curl. The token is provided by the facebook. you can get this from the app page on your facebook.
Now you need to need to add the details in parameters separate by comma. eg email, gender,homtown,bio. You can get this in detailed documentation of graph api section.
Then you have to put the facebook userid of any user. You get facebook id by facebook profile url. Now save this code and run. Facebook Graph API will return you the all of those details in json format. You only need to decode this json string and every details will be set as a key in arrays.
Step4: To access and use this fb () function you need to call this function and pass the user facebook id. Its code will go like this:-