/** * Returns an array containing four roles (administrators, developers, testers * and insights users), each role being a list of user IDs having that role. */ public function getRoles() { if (empty(self::$roles)) { global $facebook; // Calls to an app's properties must be made with an app access token // https://developers.facebook.com/docs/reference/api/application/#application_access_tokens // The app access token looks like: (APP_ID . '|' . APP_SECRET) $user_access_token = $facebook->getAccessToken(); // Back that AcceSS up $facebook->setAccessToken($this->id . '|' . $this->secret); self::$roles = array('administrators' => array(), 'developers' => array(), 'testers' => array(), 'insights users' => array()); try { $result = $facebook->api("/{$this->id}/roles"); if (isset($result['data'])) { foreach ($result['data'] as $user) { self::$roles[$user['role']][] = $user['user']; } } } catch (FacebookApiException $e) { error_log($e->getMessage()); } // Restore the user access_token $facebook->setAccessToken($user_access_token); } return self::$roles; }