Put the getEmbedJSON method into the Request object as well
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 28 Dec 2008 22:45:53 +0000 (17:45 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sun, 28 Dec 2008 22:45:53 +0000 (17:45 -0500)
framework/Service_Vimeo/lib/Horde/Service/Vimeo.php
framework/Service_Vimeo/lib/Horde/Service/Vimeo/Simple.php

index 923f434..aa6783e 100644 (file)
@@ -76,25 +76,8 @@ class Horde_Service_Vimeo {
      */
     public function getEmbedJSON($options)
     {
-        if (!is_array($options)) {
-            // Assume it's a video id, need to get the video url
-            // @TODO
-        }
-
-        // $options should be an array now
-        if (empty($options['url']) && !empty($options['video_id'])) {
-            // We were originally passed an array, but still need the url
-            // @TODO
-        }
-
-        // We should have a url now, and possibly other options.
-        $url = Util::addParameter($this->_oembed_endpoint, $options, null, false);
-
-        $req = $this->getHttpClient();
-        $response = $req->request('GET', $url);
-        $results = $response->getBody();
-
-        return $results;
+        $request = new Horde_Service_Vimeo_Request();
+        return $request->embed($options);
     }
 
     /**
index 797039e..1d64607 100644 (file)
  */
 class Horde_Service_Vimeo_Simple extends Horde_Service_Vimeo {
 
-    protected $_api_endpoint = 'http://www.vimeo.com/api/';
-    protected $_oembed_endpoint = 'http://www.vimeo.com/api/oembed.json';
-
-
     public function getActivity($criteria)
     {
     }
@@ -50,9 +46,12 @@ class Horde_Service_Vimeo_Request {
     protected $_identifier;
     protected $_method;
 
-    public function __construct($args)
+    public function __construct($args = array())
     {
-        $this->_identifier = $args['type'];
+        if (count($args) && !empty($args['type'])) {
+            $this->_identifier = $args['type'];
+
+        }
     }
 
     public function __call($name, $args)
@@ -64,6 +63,30 @@ class Horde_Service_Vimeo_Request {
        }
     }
 
+    public function embed($options)
+    {
+        if (!is_array($options)) {
+            // Assume it's a video id, need to get the video url
+            // @TODO
+        }
+
+        // $options should be an array now
+        if (empty($options['url']) && !empty($options['video_id'])) {
+            // We were originally passed an array, but still need the url
+            // @TODO
+        }
+
+        // We should have a url now, and possibly other options.
+        $url = Util::addParameter($this->_oembed_endpoint, $options, null, false);
+
+        $req = Horde_Service_Vimeo::getHttpClient();
+        $response = $req->request('GET', $url);
+        $results = $response->getBody();
+
+        return $results;
+    }
+
+
     public function run()
     {
         $req = Horde_Service_Vimeo::getHttpClient();