Add a revokeExtendedPermissions method, move get_login_url to
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 1 Mar 2009 16:57:41 +0000 (11:57 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 1 Mar 2009 17:44:39 +0000 (12:44 -0500)
the Auth class and rename getLoginUrl, rename call_upload_method
to callUploadMethod

framework/Service_Facebook/doc/facebook_example.php
framework/Service_Facebook/lib/Horde/Service/Facebook.php
framework/Service_Facebook/lib/Horde/Service/Facebook/Auth.php
framework/Service_Facebook/lib/Horde/Service/Facebook/Photos.php
framework/Service_Facebook/lib/Horde/Service/Facebook/Users.php

index c13e735..ea43202 100644 (file)
@@ -107,27 +107,33 @@ var_dump($result);
  * as a reference so when run() is called, you still have a handle to the
  * results.
  */
-$facebook->batchBegin();
-$notifications = &$facebook->notifications->get();
-$friends = &$facebook->friends->get();
-$facebook->batchEnd();
-var_dump($friends);
-var_dump($notifications);
+//$facebook->batchBegin();
+//$notifications = &$facebook->notifications->get();
+//$friends = &$facebook->friends->get();
+//$facebook->batchEnd();
+//var_dump($friends);
+//var_dump($notifications);
 
 /**
  * View a user's pictures. $uid should be the user id whose albums you want to
  * retrieve. (Permissions permitting, of course)
  */
-$albums = $facebook->photos->getAlbums($uid);
-var_dump($albums);
-$images = $facebook->photos->get('', $albums[0]['aid']);
-var_dump($images);
+//$albums = $facebook->photos->getAlbums($uid);
+//var_dump($albums);
+//$images = $facebook->photos->get('', $albums[0]['aid']);
+//var_dump($images);
 
 
 /**
  * Request the raw JSON (or XML) data
  */
-$facebook->dataFormat = Horde_Service_Facebook::DATA_FORMAT_JSON;
-$results = $facebook->photos->getAlbums($uid);
-var_dump($results);
+//$facebook->dataFormat = Horde_Service_Facebook::DATA_FORMAT_JSON;
+//$results = $facebook->photos->getAlbums($uid);
+//var_dump($results);
 
+/**
+ * Upload a photo
+ */
+$path = "/Users/mrubinsk/Desktop/horde_fb.jpg"
+$results = $facebook->photos->upload($path);
+var_dump($results);
\ No newline at end of file
index d4dfb19..9c1e93a 100644 (file)
@@ -4,8 +4,9 @@
  * rest interface.
  *
  * This code was originally a Hordified version of Facebook's official PHP
- * client. However, very little of the original code or design is left. I left
- * the original copyright notice intact below.
+ * client. However, since that client was very buggy and incomplete, very little
+ * of the original code or design is left. I left the original copyright notice
+ * intact below.
  *
  * Copyright 2009 The Horde Project (http://www.horde.org)
  *
@@ -240,17 +241,6 @@ class Horde_Service_Facebook
     }
 
     /**
-     *  Return a valid FB login URL with necessary GET parameters appended.
-     *
-     *  @return string
-     */
-    public function get_login_url($next)
-    {
-        return self::getFacebookUrl() . '/login.php?v=1.0&api_key='
-            . $this->_apiKey . ($next ? '&next=' . urlencode($next)  : '');
-    }
-
-    /**
      * Start a batch operation.
      */
     public function batchBegin()
@@ -327,7 +317,7 @@ class Horde_Service_Facebook
      *
      * @return array A dictionary representing the response.
      */
-    public function call_upload_method($method, $params, $file)
+    public function callUploadMethod($method, $params, $file)
     {
         if ($this->_batchRequest === null) {
             if (!file_exists($file)) {
index 82b0a4e..2b513a1 100644 (file)
@@ -64,6 +64,17 @@ class Horde_Service_Facebook_Auth
     }
 
     /**
+     *  Return a valid FB login URL with necessary GET parameters appended.
+     *
+     *  @return string
+     */
+    public function getLoginUrl($next)
+    {
+        return Horde_Service_Facebook::getFacebookUrl() . '/login.php?v=1.0&api_key='
+            . $this->_apiKey . ($next ? '&next=' . urlencode($next)  : '');
+    }
+
+    /**
      * Returns the URL for a user to obtain the auth token needed to generate an
      * infinite session for a web app.
      *
@@ -419,4 +430,26 @@ class Horde_Service_Facebook_Auth
         $this->_sessionKey = $sessionKey;
         $this->_session_expires = $expires;
     }
+
+    /**
+     * Revoke a previously authorizied extended permission
+     *
+     * @param $perm
+     * @param $uid
+     * @return unknown_type
+     */
+    public function revokeExtendedPermission($perm, $uid)
+    {
+        // 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);
+        }
+
+        return $this->_facebook->callMethod('Auth.revokeExtendedPermission',
+                                            array('session_key' => $skey,
+                                                  'perm' => $perm,
+                                                  'user' => $uid));
+
+    }
 }
\ No newline at end of file
index 15b06e8..506691c 100644 (file)
@@ -277,7 +277,7 @@ class Horde_Service_Facebook_Photos extends Horde_Service_Facebook_Base
         if ($this->_facebook->dataFormat == Horde_Service_Facebook::DATA_FORMAT_ARRAY) {
             $oldFormat = $this->_facebook->setInternalFormat(Horde_Service_Facebook::DATA_FORMAT_XML);
         }
-        $results = $this->_facebook->call_upload_method('facebook.photos.upload', $params, $file);
+        $results = $this->_facebook->callUploadMethod('facebook.photos.upload', $params, $file);
         if (!empty($oldFormat)) {
             $this->_facebook->setInternalFormat($oldFormat);
         }
index 11c2fe2..95bb436 100644 (file)
@@ -32,7 +32,7 @@ class Horde_Service_Facebook_Users extends Horde_Service_Facebook_Base
      * authorized your application will be returned.
      *
      * Check the wiki for fields that can be queried through this API call.
-     * Data returned from here should not be used for rendering to application
+     * Data returned from here should *not* be used for rendering to application
      * users, use users.getInfo instead, so that proper privacy rules will be
      * applied.
      *