- Remove validateSession from Facebook:: (it's in Auth)
authorMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 3 Mar 2009 23:52:55 +0000 (18:52 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 3 Mar 2009 23:55:42 +0000 (18:55 -0500)
- 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.

framework/Service_Facebook/lib/Horde/Service/Facebook.php
framework/Service_Facebook/lib/Horde/Service/Facebook/Auth.php
framework/Service_Facebook/lib/Horde/Service/Facebook/Users.php

index 9c1e93a..8deb0a1 100644 (file)
@@ -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.
index 2b513a1..cccfb13 100644 (file)
@@ -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
index 95bb436..9fb9ab9 100644 (file)
@@ -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