So, I got it to work as I would like. This may not be the best way, but after long jerks and disappointments, I hope that this can help someone with the same question to take the right path.
Source JS:
FB.getLoginStatus(function(response) { if (!response.session) { //initiate FB OAuth js popup dialog FB.ui({ method: 'oauth', display: 'page', scope: 'email', perms: 'email' }, function(response) { if (response.session) { //if permission Allowed var thesession = response.session; var thesession = eval('(' + thesession + ')'); //decode json //POSTing to local file get.user_graph.php, to fetch user info $.ajax({ type: "POST", url: "get.user_graph.php", data: "client_id=<?php echo $appId; ?>&client_secret=<?php echo $secret; ?>&sessions="+thesession.session_key+"&type=client_cred&uid="+thesession.uid, dataType: "text", success: function(user_graph){ var user_graph1 = eval('('+user_graph+')'); alert(user_graph1.name); //users name alert(user_graph1.id); //users id alert(user_graph1.email); //users email alert(user_graph1.link); //users profile link } }); } else { //if permission Not Allowed } }); } });
get.user_graph.php source:
//exchange our session for an access_token define('POSTURL', 'https://graph.facebook.com/oauth/exchange_sessions'); define('POSTVARS', 'client_id='.$_POST['client_id'].'&client_secret='.$_POST['client_secret'].'&sessions='.$_POST['sessions'].'&type=client_cred'); $curl_token = curl_init(POSTURL); curl_setopt($curl_token, CURLOPT_POST,1); curl_setopt($curl_token, CURLOPT_POSTFIELDS,POSTVARS); curl_setopt($curl_token, CURLOPT_FOLLOWLOCATION,1); curl_setopt($curl_token, CURLOPT_HEADER,0); curl_setopt($curl_token, CURLOPT_RETURNTRANSFER,1); $token = curl_exec($curl_token); $token_decoded = json_decode($token,true); //get the user graph (personal info) $user_graph = file_get_contents("https://graph.facebook.com/".$_POST['uid']."?access_token=".$token_decoded[0]['access_token']); echo $user_graph;
source share