Create the Facebook Application

Create a Facebook Application using the Facebook Developer Tool.

After creating the app go to the application settings and get the values of the parameters saying App ID and App Secret, we will have to use them later.

Authenticate Your Application

As Facebook Graph API uses OAuth for authorization, so we need to authenticate the application for the permissions of some Graph API calls we gonna use. To do this, lets jump to a new tab in your browser and copy and paste the following url into the address bar.

after you hit enter in your browser to goto the url you’ve just specified, this will ask you to login to facebook (if needed) and after you login, you'll be asked to login using your facebook app.

After you allow your app to be used with your facebook account you will be redirected to the redirect_uri you specified before, with a code sent to that page in get parameter. This url will look something like the one below:

We will need this code to request an access_token, which will be used each time we gonna query the Graph API.

Get User info from id

function callFb($url)
	$ch = curl_init();
	curl_setopt_array($ch, array(
		CURLOPT_URL = $url,

	$result = curl_exec($ch);
	return $result;

$url = "";
$access_token = callFb($url);
$access_token = substr($access_token, strpos($access_token, "=")+1, strlen($access_token));

$url = "".$_GET['id']."?access_token=$access_token";
$ret_json = callFb($url);
$user = json_decode($ret_json, true);

$url = "".$_GET['id']."/feed?access_token=$access_token";
$ret_json = callFb($url);
$user_feed = json_decode($ret_json, true);