From: Michael J. Rubinsky Date: Sat, 27 Dec 2008 00:23:31 +0000 (-0500) Subject: First step in moving service/* to framework/Service_Vimeo X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f9b1715a4a1bc0bca19691f6244cd91bfb9664de;p=horde.git First step in moving service/* to framework/Service_Vimeo Fix mistaken commit - this should be under framework --- diff --git a/framework/Service_Vimeo/doc/vimeo_example.php b/framework/Service_Vimeo/doc/vimeo_example.php new file mode 100644 index 000000000..ebce6f7c0 --- /dev/null +++ b/framework/Service_Vimeo/doc/vimeo_example.php @@ -0,0 +1,19 @@ +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 index 000000000..285684528 --- /dev/null +++ b/framework/Service_Vimeo/lib/VimeoSimple.php @@ -0,0 +1,106 @@ + + */ +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 index ebce6f7c0..000000000 --- a/service/doc/vimeo_example.php +++ /dev/null @@ -1,19 +0,0 @@ -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 index 285684528..000000000 --- a/service/lib/VimeoSimple.php +++ /dev/null @@ -1,106 +0,0 @@ - - */ -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