php - Facebook API how to allow only members of a group to access the app -


i using php code.

with code using few problems.

  1. when log on asks permission use id/username not groups.
  2. i error message: "warning: invalid argument supplied foreach() in index.php on line 23" foreach check group.

yes correct values set in code, don't want entire world know it.

<?php require 'src/facebook.php';  // create our application instance (replace appid , secret). $facebook = new facebook(array(   'appid'  => 'app id',   'secret' => 'secret', ));  // logg ut if(isset($_get['action']) && $_get['action'] === 'logout'){     $facebook->destroysession(); }  // user id $user = $facebook->getuser();  if ($user) {   try {     // proceed knowing have logged in user who's authenticated.     $user_profile = $facebook->api('/me?fields=id,name,groups','get');     $user_belongs_to_group= false;     foreach($user_profile['groups']['data'] $group){         if($group['id']===group id){ // gruppeid             $user_belongs_to_group=true;         }     }     if($user_belongs_to_group){         echo "good du tilhører gruppen";     }else{         echo "ikke good, du tilhører ikke gruppen";     }   } catch (facebookapiexception $e) {     error_log($e);     $user = null;   } }  // login or logout url needed depending on current user state. if ($user) {   $logouturl = $facebook->getlogouturl(); } else {   $loginurl = $facebook->getloginurl(); }  ?> 


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -