First step in moving service/* to framework/Service_Vimeo
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 27 Dec 2008 00:23:31 +0000 (19:23 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 27 Dec 2008 00:23:31 +0000 (19:23 -0500)
Fix mistaken commit - this should be under framework

framework/Service_Vimeo/doc/vimeo_example.php [new file with mode: 0644]
framework/Service_Vimeo/lib/VimeoSimple.php [new file with mode: 0644]
service/doc/vimeo_example.php [deleted file]
service/lib/VimeoSimple.php [deleted file]

diff --git a/framework/Service_Vimeo/doc/vimeo_example.php b/framework/Service_Vimeo/doc/vimeo_example.php
new file mode 100644 (file)
index 0000000..ebce6f7
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+
+// require_once /var/www/html/horde/horde-hatchery/service/lib/VimeoSimple.php';
+
+require_once 'Horde/Autoloader.php';
+$v = new Service_VimeoSimple();
+
+// Get the list of all user videos
+$results = unserialize($v->getClips(array('userClips' => 'user1015172')));
+
+// Get first video to embed
+$latest = $results[0]; 
+
+// Get the code to embed it
+$embed = $v->getEmbedJSON($latest['url']);
+
+// Decode the data and print out the HTML
+$results = Horde_Serialize::unserialize($embed, SERIALIZE_JSON);
+echo $results->html;
diff --git a/framework/Service_Vimeo/lib/VimeoSimple.php b/framework/Service_Vimeo/lib/VimeoSimple.php
new file mode 100644 (file)
index 0000000..2856845
--- /dev/null
@@ -0,0 +1,106 @@
+<?php
+
+/** HTTP_Request **/
+require_once 'HTTP/Request.php';
+
+/**
+ * Horde_Serivce_VimeoSimple:: wrapper around Vimeo's (http://www.vimeo.com)
+ * Simple API.
+ *
+ * Copyright 2008 The Horde Project (http://www.horde.org)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Michael J. Rubinsky <mrubinsk@horde.org>
+ */
+class Service_VimeoSimple {
+
+    protected $_api_endpoint = 'http://www.vimeo.com/api/';
+    protected $_oembed_endpoint = 'http://www.vimeo.com/api/oembed.json';
+    protected $_format = 'php';
+
+
+    public function setReturnFormat($format)
+    {
+        // TODO: Validate (json, php, xml)
+        $this->_format = $format;
+    }
+
+    /**
+     * Return an array of clips data based on the search criteria.
+     *
+     * @param array $criteria  The search criteria:
+     *     Users
+     *       userClips:
+     *       userLikes:
+     *       userIn:
+     *       userAll:
+     *       userSubscriptions:
+     *       contactsClips:
+     *       contactsLikes:
+     *
+     *     Groups
+     *       groupClips: clips in this group
+     *
+     *
+     *
+     * @param unknown_type $criteria
+     */
+    public function getClips($criteria)
+    {
+        $key = array_pop(array_keys($criteria));
+
+        switch ($key) {
+        case 'userClips':
+            $method = $criteria['userClips'] . '/clips.' . $this->_format;
+            break;
+        }
+
+        $req = new HTTP_Request($this->_api_endpoint . $method);
+        if (is_a($req, 'PEAR_Error')) {
+            return $req;
+        }
+        $req->sendRequest();
+        return $req->getResponseBody();
+    }
+
+    public function getActivity($criteria)
+    {
+    }
+
+    /**
+     * Group:
+     * User:
+     * Album:
+     * Channel:
+     *
+     *
+     * @param unknown_type $criteria
+     */
+    public function getInfo($criteria)
+    {
+    }
+
+
+    /**
+     * Get the raw JSON response containing the data to embed a single video.
+     *
+     * @param string $clipUrl  The URL of the video to embed.
+     *
+     * @return JSON encoded data
+     */
+    public function getEmbedJSON($clipUrl)
+    {
+        $url = $this->_oembed_endpoint . '?url=' . rawurlencode($clipUrl);
+        $req = new HTTP_Request($url);
+        //@TODO: We should probably throw an exception here.
+        if (is_a($req, 'PEAR_Error')) {
+            return $req;
+        }
+        $req->sendRequest();
+        $response = $req->getResponseBody();
+        return $response;
+    }
+
+}
\ No newline at end of file
diff --git a/service/doc/vimeo_example.php b/service/doc/vimeo_example.php
deleted file mode 100644 (file)
index ebce6f7..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-// require_once /var/www/html/horde/horde-hatchery/service/lib/VimeoSimple.php';
-
-require_once 'Horde/Autoloader.php';
-$v = new Service_VimeoSimple();
-
-// Get the list of all user videos
-$results = unserialize($v->getClips(array('userClips' => 'user1015172')));
-
-// Get first video to embed
-$latest = $results[0]; 
-
-// Get the code to embed it
-$embed = $v->getEmbedJSON($latest['url']);
-
-// Decode the data and print out the HTML
-$results = Horde_Serialize::unserialize($embed, SERIALIZE_JSON);
-echo $results->html;
diff --git a/service/lib/VimeoSimple.php b/service/lib/VimeoSimple.php
deleted file mode 100644 (file)
index 2856845..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-<?php
-
-/** HTTP_Request **/
-require_once 'HTTP/Request.php';
-
-/**
- * Horde_Serivce_VimeoSimple:: wrapper around Vimeo's (http://www.vimeo.com)
- * Simple API.
- *
- * Copyright 2008 The Horde Project (http://www.horde.org)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Michael J. Rubinsky <mrubinsk@horde.org>
- */
-class Service_VimeoSimple {
-
-    protected $_api_endpoint = 'http://www.vimeo.com/api/';
-    protected $_oembed_endpoint = 'http://www.vimeo.com/api/oembed.json';
-    protected $_format = 'php';
-
-
-    public function setReturnFormat($format)
-    {
-        // TODO: Validate (json, php, xml)
-        $this->_format = $format;
-    }
-
-    /**
-     * Return an array of clips data based on the search criteria.
-     *
-     * @param array $criteria  The search criteria:
-     *     Users
-     *       userClips:
-     *       userLikes:
-     *       userIn:
-     *       userAll:
-     *       userSubscriptions:
-     *       contactsClips:
-     *       contactsLikes:
-     *
-     *     Groups
-     *       groupClips: clips in this group
-     *
-     *
-     *
-     * @param unknown_type $criteria
-     */
-    public function getClips($criteria)
-    {
-        $key = array_pop(array_keys($criteria));
-
-        switch ($key) {
-        case 'userClips':
-            $method = $criteria['userClips'] . '/clips.' . $this->_format;
-            break;
-        }
-
-        $req = new HTTP_Request($this->_api_endpoint . $method);
-        if (is_a($req, 'PEAR_Error')) {
-            return $req;
-        }
-        $req->sendRequest();
-        return $req->getResponseBody();
-    }
-
-    public function getActivity($criteria)
-    {
-    }
-
-    /**
-     * Group:
-     * User:
-     * Album:
-     * Channel:
-     *
-     *
-     * @param unknown_type $criteria
-     */
-    public function getInfo($criteria)
-    {
-    }
-
-
-    /**
-     * Get the raw JSON response containing the data to embed a single video.
-     *
-     * @param string $clipUrl  The URL of the video to embed.
-     *
-     * @return JSON encoded data
-     */
-    public function getEmbedJSON($clipUrl)
-    {
-        $url = $this->_oembed_endpoint . '?url=' . rawurlencode($clipUrl);
-        $req = new HTTP_Request($url);
-        //@TODO: We should probably throw an exception here.
-        if (is_a($req, 'PEAR_Error')) {
-            return $req;
-        }
-        $req->sendRequest();
-        $response = $req->getResponseBody();
-        return $response;
-    }
-
-}
\ No newline at end of file