Diffs
Services_Ustream/trunk/src/Services/Ustream/Stream.php
@@ -3,6 +3,8 @@
/**
* Services_Ustream
*
+ * PHP version 5
+ *
* LICENSE
*
* Copyright (c) 2009, Kimiaki Makino <makino@gagne.jp>
@@ -35,43 +37,80 @@
* @category Services
* @package Services_Ustream
* @author Kimiaki Makino <makino@gagne.jp>
- * @copyright 2009 Kimiaki Makino
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version $Id$
+ * @copyright 2009 Kimiaki Makino
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version SVN: $Id$
+ * @link http://openpear.otg/package/Services_Ustream
+ * @since File available since Release 0.1
*/
+
+/**
+ * Uses Services_Ustream_Abstract
+ */
require_once 'Services/Ustream/Abstract.php';
+/**
+ * Abstract class for Services_Ustream
+ *
+ * @category Services
+ * @package Services_Ustream
+ * @author Kimiaki Makino <makino@gagne.jp>
+ * @copyright 2009 Kimiaki Makino
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://openpear.otg/package/Services_Ustream
+ */
+
class Services_Ustream_Stream extends Services_Ustream_Abstract
{
- protected $_subject = 'stream';
+ protected $subject = 'stream';
+ /**
+ * getRecent
+ *
+ * @return mixed Services_Ustream_Result | string
+ */
public function getRecent()
{
$this->setParam('uid', 'all');
$this->setParam('command', 'getRecent');
- return $this->_sendRequest();
+ return $this->sendRequest();
}
+ /**
+ * getMostViewers
+ *
+ * @return mixed Services_Ustream_Result | string
+ */
public function getMostViewers()
{
$this->setParam('uid', $uid);
$this->setParam('command', 'getMostViewers');
- return $this->_sendRequest();
+ return $this->sendRequest();
}
+ /**
+ * getRandom
+ *
+ * @return mixed Services_Ustream_Result | string
+ */
public function getRandom()
{
$this->setParam('uid', 'all');
$this->setParam('command', 'getRandom');
- return $this->_sendRequest();
+ return $this->sendRequest();
}
+ /**
+ * getAllNews
+ *
+ * @return mixed Services_Ustream_Result | string
+ */
public function getAllNew()
{
$this->setParam('uid', 'all');
$this->setParam('command', 'getAllNew');
- return $this->_sendRequest();
+ return $this->sendRequest();
}
}
Services_Ustream/trunk/src/Services/Ustream/User.php
@@ -3,6 +3,8 @@
/**
* Services_Ustream
*
+ * PHP version 5
+ *
* LICENSE
*
* Copyright (c) 2009, Kimiaki Makino <makino@gagne.jp>
@@ -35,24 +37,55 @@
* @category Services
* @package Services_Ustream
* @author Kimiaki Makino <makino@gagne.jp>
- * @copyright 2009 Kimiaki Makino
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version $Id$
+ * @copyright 2009 Kimiaki Makino
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version SVN: $Id$
+ * @link http://openpear.otg/package/Services_Ustream
+ * @since File available since Release 0.1
*/
+/**
+ * Uses Services_Ustream_Abstract
+ */
require_once 'Services/Ustream/Abstract.php';
+/**
+ * Access to User command class for Services_Ustream
+ *
+ * @category Services
+ * @package Services_Ustream
+ * @author Kimiaki Makino <makino@gagne.jp>
+ * @copyright 2009 Kimiaki Makino
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://openpear.otg/package/Services_Ustream
+ */
+
class Services_Ustream_User extends Services_Ustream_Abstract
{
- protected $_subject = 'user';
+ protected $subject = 'user';
+ /**
+ * getInfo
+ *
+ * @param string $uid UID
+ *
+ * @return mixed Services_Ustream_Result | string
+ */
public function getInfo($uid)
{
$this->setParam('uid', $uid);
$this->setParam('command', 'getInfo');
- return $this->_sendRequest();
+ return $this->sendRequest();
}
+ /**
+ * getValueOf
+ *
+ * @param string $uid UID
+ * @param string $property property
+ *
+ * @return mixed Services_Ustream_Result | string
+ */
public function getValueOf($uid, $property)
{
$_properties = array('id', 'userName', 'registeredAt', 'url', 'gender',
@@ -61,38 +94,66 @@
$this->setParam('uid', $uid);
$this->setParam('command', 'getValueOf');
$this->setParam('params', $property);
- return $this->_sendRequest();
+ return $this->sendRequest();
} else {
throw new Services_Ustream_Exception('Invalid property.');
}
}
+ /**
+ * getId
+ *
+ * @param string $uid UID
+ *
+ * @return mixed Services_Ustream_Result | string
+ */
public function getId($uid)
{
$this->setParam('uid', $uid);
$this->setParam('command', 'getId');
- return $this->_sendRequest();
+ return $this->sendRequest();
}
+ /**
+ * listAllChannels
+ *
+ * @param string $uid UID
+ *
+ * @return mixed Services_Ustream_Result | string
+ */
public function listAllChannels($uid)
{
$this->setParam('uid', $uid);
$this->setParam('command', 'listAllChannels');
- return $this->_sendRequest();
+ return $this->sendRequest();
}
+ /**
+ * listAllVideos
+ *
+ * @param string $uid UID
+ *
+ * @return mixed Services_Ustream_Result | string
+ */
public function listAllVideos($uid)
{
$this->setParam('uid', $uid);
$this->setParam('command', 'listAllVideos');
- return $this->_sendRequest();
+ return $this->sendRequest();
}
+ /**
+ * getComments
+ *
+ * @param string $uid UID
+ *
+ * @return mixed Services_Ustream_Result | string
+ */
public function getComments($uid)
{
$this->setParam('uid', $uid);
$this->setParam('command', 'getComments');
- return $this->_sendRequest();
+ return $this->sendRequest();
}
}
Services_Ustream/trunk/src/Services/Ustream/Abstract.php
@@ -3,6 +3,8 @@
/**
* Services_Ustream
*
+ * PHP version 5
+ *
* LICENSE
*
* Copyright (c) 2009, Kimiaki Makino <makino@gagne.jp>
@@ -35,24 +37,58 @@
* @category Services
* @package Services_Ustream
* @author Kimiaki Makino <makino@gagne.jp>
- * @copyright 2009 Kimiaki Makino
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version $Id$
+ * @copyright 2009 Kimiaki Makino
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version SVN: $Id$
+ * @link http://openpear.otg/package/Services_Ustream
+ * @since File available since Release 0.1
*/
+
+/**
+ * Uses HTTP_Request2 class to send and receive data from Ustream API server.
+ */
require_once 'HTTP/Request2.php';
+
+/**
+ * Uses Services_Ustream_Exception class for exception.
+ */
require_once 'Services/Ustream/Exception.php';
+
+/**
+ * Uses Services_Ustream_Result class for result
+ */
require_once 'Services/Ustream/Result.php';
+
+/**
+ * Abstract class for Services_Ustream
+ *
+ * @category Services
+ * @package Services_Ustream
+ * @author Kimiaki Makino <makino@gagne.jp>
+ * @copyright 2009 Kimiaki Makino
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://openpear.otg/package/Services_Ustream
+ */
+
abstract class Services_Ustream_Abstract
{
- protected $_baseUrl = 'http://api.ustream.tv';
- protected $_apiKey;
- protected $_subject;
- protected $_params;
- protected $_responseType;
- protected $_request;
+ protected $baseUrl = 'http://api.ustream.tv';
+ protected $apiKey;
+ protected $subject;
+ protected $requestParams;
+ protected $responseType;
+ protected $request;
+ /**
+ * Constructor
+ *
+ * @param string $apiKey Ustream API Key.
+ * @param string $responseType Response type (xml,json,php,html)
+ * @param array $config Settings for HTTP_Request2
+ */
+
public function __construct($apiKey = '', $responseType = 'php', $config = array())
{
if (isset($apiKey)) {
@@ -60,75 +96,129 @@
}
$this->setResponseType($responseType);
- if ($this->_request == '') {
- $this->_request = new HTTP_Request2();
- $this->_request->setConfig($config);
- $this->_request->setHeader('User-Agent', 'Services_Ustream');
+ if ($this->request == '') {
+ $this->request = new HTTP_Request2();
+ $this->request->setConfig($config);
+ $this->request->setHeader('User-Agent', 'Services_Ustream');
}
}
- protected function _sendRequest()
+ /**
+ * Send request to server.
+ *
+ * @return mixed Services_Ustream_Result object or result string.
+ */
+ protected function sendRequest()
{
- if (!$this->_apiKey) {
+ if (!$this->apiKey) {
throw new Services_Ustream_Exception('Empty API Key');
}
- $this->setParam('key', $this->_apiKey);
- $this->setParam('subject', $this->_subject);
- $url = sprintf('%s/%s?%s', $this->_baseUrl, $this->_responseType, http_build_query($this->_params));
+ $this->setParam('key', $this->apiKey);
+ $this->setParam('subject', $this->subject);
+ $url = sprintf(
+ '%s/%s?%s',
+ $this->baseUrl,
+ $this->responseType,
+ http_build_query($this->requestParams)
+ );
try {
- $response = $this->_request->setUrl($url)->send();
+ $response = $this->request->setUrl($url)->send();
if ($response->getStatus() == 200) {
- if ($this->_responseType == 'xml' || $this->_responseType == 'php') {
- return new Services_Ustream_Result($response->getBody(), $this->_responseType);
+ if ($this->responseType == 'xml'
+ || $this->responseType == 'php'
+ ) {
+ return new Services_Ustream_Result($response->getBody(),
+ $this->responseType);
} else {
return $response->getBody();
}
} else {
- throw new Services_Ustream_Exception('Server returned status: ' . $response->getStatus());
+ throw new Services_Ustream_Exception('Server returned status: '
+ . $response->getStatus());
}
} catch (HTTP_Request2_Exception $e) {
throw new Services_Ustream_Exception($e->getMessage(), $e->getCode());
}
}
+ /**
+ * Set API Key
+ *
+ * @param string $apiKey Ustream API key.
+ *
+ * @return object
+ */
public function setApiKey($apiKey)
{
- $this->_apiKey = $apiKey;
+ $this->apiKey = $apiKey;
return $this;
}
+ /**
+ * Set API response type.
+ *
+ * @param string $type Response type (xml,json,php,html)
+ *
+ * @return object
+ */
public function setResponseType($type)
{
if (in_array($type, array('xml', 'json', 'php', 'html'))) {
- $this->_responseType = $type;
+ $this->responseType = $type;
} else {
throw new Services_Ustream_Exception('Invalid response type.');
}
return $this;
}
+ /**
+ * Set parameter for request
+ *
+ * @param string $name name
+ * @param string $value value
+ *
+ * @return object
+ */
public function setParam($name, $value)
{
- $this->_params[$name] = $value;
+ $this->requestParams[$name] = $value;
return $this;
}
+ /**
+ * Set page of result.
+ *
+ * @param integer $page page num
+ *
+ * @return object
+ */
public function setPage($page)
{
return $this->setParam('page', (int) $page);
}
-
+
+ /**
+ * Set limit of result
+ *
+ * @param interger $limit Limit
+ *
+ * @return object
+ */
public function setLimit($limit)
{
return $this->setParam('limit', (int) $limit);
}
-
+ /**
+ * Clear parameters
+ *
+ * @return object
+ */
public function clearParams()
{
- $this->_params = array();
+ $this->requestParams = array();
return $this;
}
Services_Ustream/trunk/src/Services/Ustream/System.php
@@ -3,6 +3,8 @@
/**
* Services_Ustream
*
+ * PHP version 5
+ *
* LICENSE
*
* Copyright (c) 2009, Kimiaki Makino <makino@gagne.jp>
@@ -35,29 +37,56 @@
* @category Services
* @package Services_Ustream
* @author Kimiaki Makino <makino@gagne.jp>
- * @copyright 2009 Kimiaki Makino
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version $Id$
+ * @copyright 2009 Kimiaki Makino
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version SVN: $Id$
+ * @link http://openpear.otg/package/Services_Ustream
+ * @since File available since Release 0.1
*/
+/**
+ * Uses Services_Ustream_Abstract
+ */
require_once 'Services/Ustream/Abstract.php';
+/**
+ * System class for Services_Ustream
+ *
+ * @category Services
+ * @package Services_Ustream
+ * @author Kimiaki Makino <makino@gagne.jp>
+ * @copyright 2009 Kimiaki Makino
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://openpear.otg/package/Services_Ustream
+ */
class Services_Ustream_System extends Services_Ustream_Abstract
{
- protected $_subject = 'system';
+ protected $subject = 'system';
+ /**
+ * heartBeat
+ *
+ * @return mixed Services_Ustream_Result | string
+ */
public function heartBeat()
{
$this->setParam('command', 'heartBeat');
$this->setParam('uid', 'status');
- return $this->_sendRequest();
+
+ return $this->sendRequest();
}
+ /**
+ * ping
+ *
+ * @return mixed Services_Ustream_Result | string
+ */
public function ping()
{
$this->setparam('command', 'ping');
$this->setParam('uid', 'status');
- return $this->_sendRequest();
+
+ return $this->sendRequest();
}
}
Services_Ustream/trunk/src/Services/Ustream/Search.php
@@ -3,6 +3,8 @@
/**
* Services_Ustream
*
+ * PHP version 5
+ *
* LICENSE
*
* Copyright (c) 2009, Kimiaki Makino <makino@gagne.jp>
@@ -35,128 +37,240 @@
* @category Services
* @package Services_Ustream
* @author Kimiaki Makino <makino@gagne.jp>
- * @copyright 2009 Kimiaki Makino
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version $Id$
+ * @copyright 2009 Kimiaki Makino
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version SVN: $Id$
+ * @link http://openpear.otg/package/Services_Ustream
+ * @since File available since Release 0.1
*/
+/**
+ * Uses Services_Ustream_Abstract
+ */
require_once 'Services/Ustream/Abstract.php';
+/**
+ * Search class for Services_Ustream
+ *
+ * @category Services
+ * @package Services_Ustream
+ * @author Kimiaki Makino <makino@gagne.jp>
+ * @copyright 2009 Kimiaki Makino
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://openpear.otg/package/Services_Ustream
+ */
class Services_Ustream_Search extends Services_Ustream_Abstract
{
- protected $_subject = 'search';
- protected $_command;
- protected $_scopeOrSorting;
- protected $_searchParams = array();
-
+ protected $subject = 'search';
+ protected $command;
+ protected $scopeOrSorting;
+ protected $searchParams = array();
+
+ /**
+ * Set command
+ *
+ * @param string $command Command name
+ *
+ * @return object
+ * @throws Services_Ustream_Exception
+ */
public function command($command)
{
- $_commands = array('user', 'channel', 'stream', 'video');
- if (in_array($command, $_commands)) {
- $this->_command = $command;
+ $commands = array('user', 'channel', 'stream', 'video');
+ if (in_array($command, $commands)) {
+ $this->command = $command;
} else {
throw new Services_Ustream_Exception('Invalid command.');
}
return $this;
}
+ /**
+ * Set scope
+ *
+ * @param string $scope scope
+ *
+ * @return object
+ */
public function scope($scope)
{
- $this->_scopeOrSorting = $scope;
+ $this->scopeOrSorting = $scope;
return $this;
}
+ /**
+ * Set uid
+ *
+ * @param string $uid UID
+ *
+ * @return object
+ */
public function uid($uid)
{
- $this->_scopeOrSorting = $uid;
+ $this->scopeOrSorting = $uid;
return $this;
}
+ /**
+ * newest
+ *
+ * @param bool $flag newst or not
+ *
+ * @return object
+ */
public function newest($flag = true)
{
- $this->_scopeOrSorting =
- ($flag) ? 'newest' : '!newest';
+ $this->scopeOrSorting = ($flag) ? 'newest' : '!newest';
+
return $this;
}
+ /**
+ * recent
+ *
+ * @param bool $flag recent or not
+ *
+ * @return object
+ */
public function recent($flag = true)
{
- $this->_scopeOrSorting =
- ($flag) ? 'recent' : '!recent';
+ $this->scopeOrSorting = ($flag) ? 'recent' : '!recent';
return $this;
}
+ /**
+ * all
+ *
+ * @return Services_Ustream_Search
+ */
public function all()
{
- $this->_scopeOrSorting = 'all';
+ $this->scopeOrSorting = 'all';
return $this;
}
+ /**
+ * live
+ *
+ * @return Services_Ustream_Search
+ */
public function live()
{
- $this->_scopeOrSorting = 'live';
+ $this->scopeOrSorting = 'live';
return $this;
}
+ /**
+ * popular
+ *
+ * @return Services_Ustream_Search
+ */
public function popular()
{
- $this->_scopeOrSorting = 'popular';
+ $this->scopeOrSorting = 'popular';
return $this;
}
+ /**
+ * where
+ *
+ * @param string $key Search key
+ *
+ * @return Services_Ustream_Search
+ */
public function where($key)
{
- $this->_searchParams[0] = $key;
+ $this->searchParams[0] = $key;
return $this;
}
+ /**
+ * like
+ *
+ * @param string $value value
+ *
+ * @return Services_Ustream_Search
+ */
public function like($value)
{
- $this->_searchParams[1] = 'like:' . $value;
+ $this->searchParams[1] = 'like:' . $value;
return $this;
}
+ /**
+ * eq
+ *
+ * @param string $value value
+ *
+ * @return Services_Ustream_Search
+ */
public function eq($value)
{
- $this->_searchParams[1] = 'eq:' . $value;
+ $this->searchParams[1] = 'eq:' . $value;
return $this;
}
+ /**
+ * lt
+ *
+ * @param string $value value
+ *
+ * @return Services_Ustream_Search
+ */
public function lt($value)
{
- $this->_searchParams[1] = 'lt:' . $value;
+ $this->searchParams[1] = 'lt:' . $value;
return $this;
}
+ /**
+ * gt
+ *
+ * @param string $value value
+ *
+ * @return Services_Ustream_Search
+ */
public function gt($value)
{
- $this->_searchParams[1] = 'gt:' . $value;
+ $this->searchParams[1] = 'gt:' . $value;
return $this;
}
+ /**
+ * Send request and get result
+ *
+ * @return mixed Services_Ustream_Result | string
+ * @throws Services_Ustream_Exception
+ */
public function query()
{
- $params = implode(':', $this->_searchParams);
- $url = sprintf('%s/%s/%s/%s/%s/%s?key=%s',
- $this->_baseUrl,
- $this->_responseType,
- $this->_command,
- $this->_scopeOrSorting,
- $this->_subject,
- $params,
- $this->_apiKey);
+ $params = implode(':', $this->searchParams);
+ $url = sprintf(
+ '%s/%s/%s/%s/%s/%s?key=%s',
+ $this->baseUrl,
+ $this->responseType,
+ $this->command,
+ $this->scopeOrSorting,
+ $this->subject,
+ $params,
+ $this->apiKey
+ );
echo $url;
try {
- $response = $this->_request->setUrl($url)->send();
+ $response = $this->request->setUrl($url)->send();
if ($response->getStatus() == 200) {
- if ($this->_responseType == 'xml' || $this->_responseType == 'php') {
- return new Services_Ustream_Result($response->getBody(), $this->_responseType);
+ if ($this->responseType == 'xml'
+ || $this->responseType == 'php'
+ ) {
+ return new Services_Ustream_Result($response->getBody(),
+ $this->responseType);
} else {
return $response->getBody();
}
} else {
- throw new Services_Ustream_Exception('Server returned status: ' . $response->getStatus());
+ throw new Services_Ustream_Exception('Server returned status: '
+ . $response->getStatus());
}
} catch (HTTP_Request2_Exception $e) {
throw new Services_Ustream_Exception($e->getMessage(), $e->getCode());
Services_Ustream/trunk/src/Services/Ustream/Video.php
@@ -3,6 +3,8 @@
/**
* Services_Ustream
*
+ * PHP version 5
+ *
* LICENSE
*
* Copyright (c) 2009, Kimiaki Makino <makino@gagne.jp>
@@ -35,29 +37,55 @@
* @category Services
* @package Services_Ustream
* @author Kimiaki Makino <makino@gagne.jp>
- * @copyright 2009 Kimiaki Makino
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version $Id$
+ * @copyright 2009 Kimiaki Makino
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version SVN: $Id$
+ * @link http://openpear.otg/package/Services_Ustream
+ * @since File available since Release 0.1
*/
+/**
+ * Uses Services_Ustream_Abstract
+ */
require_once 'Services/Ustream/Abstract.php';
+/**
+ * Video class for Services_Ustream
+ *
+ * @category Services
+ * @package Services_Ustream
+ * @author Kimiaki Makino <makino@gagne.jp>
+ * @copyright 2009 Kimiaki Makino
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://openpear.otg/package/Services_Ustream
+ */
class Services_Ustream_Video extends Services_Ustream_Abstract
{
- protected $_subject = 'video';
+ protected $subject = 'video';
/**
+ * getInfo
*
* @param integer $uid Video ID.
+ *
* @return string|Services_Ustream_Result
*/
public function getInfo($uid)
{
$this->setParam('uid', $uid);
$this->setParam('command', 'getInfo');
- return $this->_sendRequest();
+ return $this->sendRequest();
}
+ /**
+ * getValueOf
+ *
+ * @param integer $uid Video ID.
+ * @param string $property property
+ *
+ * @return string|Services_Ustream_Result
+ * @throws Services_Ustream_Exception
+ */
public function getValueOf($uid, $property)
{
$_properties = array('id', 'user', 'title', 'description', 'createdAt',
@@ -69,49 +97,81 @@
$this->setParam('uid', $uid);
$this->setParam('command', 'getValueOf');
$this->setParam('params', $property);
- return $this->_sendRequest();
+ return $this->sendRequest();
} else {
throw new Services_Ustream_Exception('Invalid property.');
}
}
+ /**
+ * getId
+ *
+ * @param string $videoUrl Video URL
+ *
+ * @return string|Services_Ustream_Result
+ */
public function getId($videoUrl)
{
$this->setParam('uid', $videoUrl);
$this->setParam('command', 'getValueOf');
$this->setParam('params', 'id');
- return $this->_sendRequest();
+ return $this->sendRequest();
}
+ /**
+ * getEmbedTag
+ *
+ * @param integer $uid Video ID.
+ *
+ * @return string|Services_Ustream_Result
+ */
public function getEmbedTag($uid)
{
$this->setParam('uid', $uid);
$this->setParam('command', 'getEmbedTag');
- return $this->_sendRequest();
+ return $this->sendRequest();
}
+ /**
+ * listAllVideos
+ *
+ * @param integer $uid Video ID.
+ *
+ * @return string|Services_Ustream_Result
+ */
public function listAllVideos($uid)
{
$this->setParam('uid', $uid);
$this->setParam('command', 'listAllVideos');
- return $this->_sendRequest();
+ return $this->sendRequest();
}
+ /**
+ * getComments
+ *
+ * @param integer $uid Video ID.
+ *
+ * @return string|Services_Ustream_Result
+ */
public function getComments($uid)
{
$this->setParam('uid', $uid);
$this->setParam('command', 'getComments');
- return $this->_sendRequest();
+ return $this->sendRequest();
}
+ /**
+ * getTags
+ *
+ * @param integer $uid Video ID.
+ *
+ * @return string|Services_Ustream_Result
+ */
public function getTags($uid)
{
$this->setParam('uid', $uid);
$this->setParam('command', 'getTags');
- return $this->_sendRequest();
+ return $this->sendRequest();
}
-
-
-
}
Services_Ustream/trunk/src/Services/Ustream/Channel.php
@@ -3,6 +3,8 @@
/**
* Services_Ustream
*
+ * PHP version 5
+ *
* LICENSE
*
* Copyright (c) 2009, Kimiaki Makino <makino@gagne.jp>
@@ -35,24 +37,54 @@
* @category Services
* @package Services_Ustream
* @author Kimiaki Makino <makino@gagne.jp>
- * @copyright 2009 Kimiaki Makino
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version $Id$
+ * @copyright 2009 Kimiaki Makino
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version SVN: $Id$
+ * @link http://openpear.otg/package/Services_Ustream
+ * @since File available since Release 0.1
*/
+/**
+ * Uses Services_Ustream_Abstract
+ */
require_once 'Services/Ustream/Abstract.php';
+/**
+ * Access to Channel command class for Services_Ustream
+ *
+ * @category Services
+ * @package Services_Ustream
+ * @author Kimiaki Makino <makino@gagne.jp>
+ * @copyright 2009 Kimiaki Makino
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://openpear.otg/package/Services_Ustream
+ */
class Services_Ustream_Channel extends Services_Ustream_Abstract
{
- protected $_subject = 'channel';
+ protected $subject = 'channel';
+ /**
+ * getInfo
+ *
+ * @param string $uid UID
+ *
+ * @return mixed Services_Ustream_Result | string
+ */
public function getInfo($uid)
{
$this->setParam('uid', $uid);
$this->setParam('command', 'getInfo');
- return $this->_sendRequest();
+ return $this->sendRequest();
}
+ /**
+ * getValueOf
+ *
+ * @param string $uid UID
+ * @param string $property property
+ *
+ * @return mixed Services_Ustream_Result | string
+ */
public function getValueOf($uid, $property)
{
$_properties = array('id', 'user', 'title', 'description', 'urlTitleName',
@@ -64,24 +96,45 @@
$this->setParam('uid', $uid);
$this->setParam('command', 'getValueOf');
$this->setParam('params', $property);
- return $this->_sendRequest();
+ return $this->sendRequest();
} else {
throw new Services_Ustream_Exception('Invalid property.');
}
}
+ /**
+ * getId
+ *
+ * @return void
+ * @throws Exception
+ */
public function getId()
{
throw new Exception(__FUNCTION__ . ' is disable now.');
}
+ /**
+ * getEmbedTag
+ *
+ * @param string $uid UID
+ *
+ * @return mixed Services_Ustream_Result | string
+ */
public function getEmbedTag($uid)
{
$this->setParam('uid', $uid);
$this->setParam('command', 'getEmbedTag');
- return $this->_sendRequest();
+ return $this->sendRequest();
}
+ /**
+ * getCustomEmbedTags
+ *
+ * @param string $uid UID
+ * @param array $opts Embed options
+ *
+ * @return mixed Services_Ustream_Result | string
+ */
public function getCustomEmbedTag($uid, $opts = array())
{
$params = '';
@@ -90,20 +143,46 @@
}
$this->setParam('uid', $uid);
$this->setParam('command', 'getCustomEmbedTag');
- if ($params) $this->setParam('params', $params);
- return $this->_sendRequest();
+ if ($params) {
+ $this->setParam('params', $params);
+ }
+ return $this->sendRequest();
}
+ /**
+ * listAllChannels
+ *
+ * @param string $uid UID
+ *
+ * @return void
+ * @throws Exception
+ */
public function listAllChannels($uid)
{
throw new Exception(__FUNCTION__ . 'is disable now.');
}
+ /**
+ * getComments
+ *
+ * @param string $uid UID
+ *
+ * @return void
+ * @throws Exception
+ */
public function getComments($uid)
{
throw new Exception(__FUNCTION__ . 'is disable now.');
}
+ /**
+ * getTags
+ *
+ * @param string $uid UID
+ *
+ * @return void
+ * @throws Exception
+ */
public function getTags($uid)
{
throw new Exception(__FUNCTION__ . 'is disable now.');
Services_Ustream/trunk/src/Services/Ustream.php
@@ -1,71 +1,85 @@
-<?php
-/* vim: set expandtab tabstop=4 shiftwidth=4: */
-/**
- * Services_Ustream
- *
- * LICENSE
- *
- * Copyright (c) 2009, Kimiaki Makino <makino@gagne.jp>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category Services
- * @package Services_Ustream
- * @author Kimiaki Makino <makino@gagne.jp>
- * @copyright 2009 Kimiaki Makino
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version $Id$
- */
-
-
-class Services_Ustream
-{
- const VERSION = '0.2.1';
-
- protected static $_commands = array('Channel', 'User', 'Search', 'Stream', 'System', 'Video');
-
-
- /**
- * factory
- *
- * @param string channel,user,search,stream,system,video
- * @param string xml,json,php,html
- * @param array HTTP_Request2 config.
- * @return Services_Ustream_Abstract
- * @throws Services_Ustream_Exception
- */
- public static function factory($command, $apiKey = null, $responseType = 'php', $config = array())
- {
- if (!in_array(ucwords($command), self::$_commands)) {
- require_once 'Services/Ustream/Exception.php';
- throw new Services_Ustream_Exception('Invalid API command.');
- }
- require_once 'Services/Ustream/' . ucwords($command) . '.php';
- $class = 'Services_Ustream_' . ucwords($command);
-
- return new $class($apiKey, $responseType, $config);
- }
+<?php
+/* vim: set expandtab tabstop=4 shiftwidth=4: */
+/**
+ * Services_Ustream
+ *
+ * PHP version 5
+ *
+ * LICENSE
+ *
+ * Copyright (c) 2009, Kimiaki Makino <makino@gagne.jp>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category Services
+ * @package Services_Ustream
+ * @author Kimiaki Makino <makino@gagne.jp>
+ * @copyright 2009 Kimiaki Makino
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version SVN: $Id$
+ * @link http://openpear.otg/package/Services_Ustream
+ * @since File available since Release 0.1
+ */
+
+
+/**
+ * Factory class for Services_Ustream
+ *
+ * @category Services
+ * @package Services_Ustream
+ * @author Kimiaki Makino <makino@gagne.jp>
+ * @copyright 2009 Kimiaki Makino
+ * @license http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link http://openpear.otg/package/Services_Ustream
+ * @since File available since Release 0.1
+ */
+class Services_Ustream
+{
+ const VERSION = '0.2.0';
+ private static $_commands = array(
+ 'Channel', 'User', 'Search', 'Stream', 'System', 'Video');
+
+ /**
+ * factory
+ *
+ * @param string $command Ustream API command.
+ * @param string $apiKey Ustream API Key.
+ * @param string $responseType Response type.
+ *
+ * @return object Services_Ustream_Abstract
+ */
+ public static function factory($command, $apiKey = null, $responseType = 'php')
+ {
+ if (!in_array(ucwords($command), self::$_commands)) {
+ include 'Services/Ustream/Exception.php';
+ throw new Services_Ustream_Exception('Invalid API command.');
+ }
+ include 'Services/Ustream/' . ucwords($command) . '.php';
+ $class = 'Services_Ustream_' . ucwords($command);
+
+ return new $class($apiKey, $responseType);
+ }
}
\ No newline at end of file