From 0ff22217fdd296ffc5a179c78ceade51caf669e7 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Tue, 3 Mar 2009 18:52:55 -0500 Subject: [PATCH] - Remove validateSession from Facebook:: (it's in Auth) - Add a revokeAuthorization() method to remove an app from a user's profile completely. - Add Users::getStatus() for retrieving, well, the user's current status. --- .../Service_Facebook/lib/Horde/Service/Facebook.php | 9 --------- .../lib/Horde/Service/Facebook/Auth.php | 20 +++++++++++++++++++- .../lib/Horde/Service/Facebook/Users.php | 15 +++++++++++++++ 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/framework/Service_Facebook/lib/Horde/Service/Facebook.php b/framework/Service_Facebook/lib/Horde/Service/Facebook.php index 9c1e93aa0..8deb0a1c5 100644 --- a/framework/Service_Facebook/lib/Horde/Service/Facebook.php +++ b/framework/Service_Facebook/lib/Horde/Service/Facebook.php @@ -188,15 +188,6 @@ class Horde_Service_Facebook } /** - * Initialize the object - check to see if we have a valid FB - * session, verify the signature etc... - */ - public function validateSession() - { - return $this->auth->validateSession(empty($this->_context['no_resolve'])); - } - - /** * Lazy load the facebook classes. * * @param string $value The lowercase representation of the subclass. diff --git a/framework/Service_Facebook/lib/Horde/Service/Facebook/Auth.php b/framework/Service_Facebook/lib/Horde/Service/Facebook/Auth.php index 2b513a151..cccfb131a 100644 --- a/framework/Service_Facebook/lib/Horde/Service/Facebook/Auth.php +++ b/framework/Service_Facebook/lib/Horde/Service/Facebook/Auth.php @@ -71,7 +71,7 @@ class Horde_Service_Facebook_Auth public function getLoginUrl($next) { return Horde_Service_Facebook::getFacebookUrl() . '/login.php?v=1.0&api_key=' - . $this->_apiKey . ($next ? '&next=' . urlencode($next) : ''); + . $this->_facebook->apiKey . ($next ? '&next=' . urlencode($next) : ''); } /** @@ -452,4 +452,22 @@ class Horde_Service_Facebook_Auth 'user' => $uid)); } + + /** + * Revoke all application permissions for the current session user. + * + */ + function revokeAuthorization() + { + // Session key is *required* + if (!$skey = $this->getSessionKey()) { + throw new Horde_Service_Facebook_Exception('session_key is required', + Horde_Service_Facebook_ErrorCodes::API_EC_SESSION_REQUIRED); + } + + $this->_facebook->callMethod('Auth.revokeAuthorization', + array('session_key' => $skey)); + $this->expireSession(); + + } } \ No newline at end of file diff --git a/framework/Service_Facebook/lib/Horde/Service/Facebook/Users.php b/framework/Service_Facebook/lib/Horde/Service/Facebook/Users.php index 95bb4364e..9fb9ab961 100644 --- a/framework/Service_Facebook/lib/Horde/Service/Facebook/Users.php +++ b/framework/Service_Facebook/lib/Horde/Service/Facebook/Users.php @@ -163,4 +163,19 @@ class Horde_Service_Facebook_Users extends Horde_Service_Facebook_Base return $this->_facebook->callMethod('facebook.users.setStatus', $params); } + public function &getStatus($uid = null, $limit = 1) + { + if (empty($uid) && !$skey = $this->_facebook->auth->getSessionKey()) { + throw new Horde_Service_Facebook_Exception('users.setStatus requires a uid or a session_key', + Horde_Service_Facebook_ErrorCodes::API_EC_PARAM_SESSION_KEY); + } + + $params = array('session_key' => $skey, 'limit' => $limit); + if (!empty($user)) { + $params['uid'] = $user; + } + + return $this->_facebook->callMethod('Status.get', $params); + } + } \ No newline at end of file -- 2.11.0