A Demo Facebook App for Extracting User Details

I have been thinking of extracting user details of a facebook profile(if we have user’s permission) and found this php script.you can create a facebook demo app to see the result.you ‘ll need to dump this script as index.php along with facebook.php and base_facebook.php to your hosting server.these files are available at github.com/facebook/php-sdk.

currently i am hosting my app at heroku.com you can also consider this for your need.heroku’s service is cool and most of them are free.

Now you will need to register a facebook app at developers.facebook.com.you will get a unique ‘appId’ and ‘Secret’. put the exact values in the index.php and now your heroku app address(something like myapp.herokuapp.com once you have created it) while registering for the app at developers.facebook.com.

My Demo App is available at Demo App below is the code for index.php. have Fun while creating your first Facebook App :)

(user-details.php) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

require './facebook.php';

$facebook = new Facebook(array(
'appId' => '',
'secret' => '',
'cookie' => true,
));

$user_profile = null;

$user = $facebook->getUser();
$loginUrl = $facebook->getLoginUrl(
array(
    'req_perms' => 'email,publish_stream,user_birthday,read_stream'
    ));

if($user)
{
    $user_profile=$facebook->api('/me');
    echo "Welcome ".$user_profile['name'] .":";
          
  echo "Your Profile Summary.<br />" ;


  echo "<pre>"; print_r($user_profile); echo "</pre>";

  
}
if (!$user)
{
   echo "<script type=\"text/javascript\">\ntop.location.href = \"$loginUrl\";\n</script>";
}

?>

<html>
<title>FACEBOOK USER DETAILS</title>
</html>

Comments