Current Path : /var/www/html/
Upload File :
Current File : /var/www/html/invite_friend.php

<?php
  // Remember to copy files from the SDK's src/ directory to a
  // directory in your application on the server, such as php-sdk/
  require_once('fbphp-sdk/facebook.php');

  $config = array(
    'appId' => '267984193361306',
    'secret' => '049d08c835d4fa0c94140099b5542502',
    'allowSignedRequest' => false // optional but should be set to false for non-canvas apps
  );

  $facebook = new Facebook($config);
  $user_id = $facebook->getUser();

?>
<html>
  <head></head>
  <body>

  <?php
    if($user_id) {

      // We have a user ID, so probably a logged in user.
      // If not, we'll get an exception, which we handle below.
      try {

        $friendList = $facebook->api('/me/friends?fields=id,name,installed','GET');
        echo "NUmber of freinfds: ". count($friendList['data']);
        foreach($friendList['data'] as $friend){
          if(count($friend) == 2){
            
            echo $friend['name'] . " " . $friend ['id'];//. " " . $friend ['installed'];
           // echo $friend['name']." ; ". $friend ['id'];
         }
        }

      //  echo "Name: " . $user_profile['name'];

      } catch(FacebookApiException $e) {
        // If the user is logged out, you can have a 
        // user ID even though the access token is invalid.
        // In this case, we'll get an exception, so we'll
        // just ask the user to login again here.
        $login_url = $facebook->getLoginUrl(); 
        echo 'Please <a href="' . $login_url . '">login.</a>';
        error_log($e->getType());
        error_log($e->getMessage());
      }   
    } else {

      // No user, print a link for the user to login
      $login_url = $facebook->getLoginUrl();
      echo 'Please <a href="' . $login_url . '">login.</a>';

    }

  ?>

  </body>
</html>

,