PageRenderTime 48ms CodeModel.GetById 39ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/plugin/PBAPI/PBAPI/Methods/base.php

https://bitbucket.org/chamilo/chamilo-ext-repo-photobucket-dev/
PHP | 166 lines | 74 code | 21 blank | 71 comment | 12 complexity | 5ad9bdb9514228c61a94991ea8f33cfe MD5 | raw file
  1<?php
  2
  3use common\libraries\Path;
  4/**
  5 * Photobucket API 
  6 * Fluent interface for PHP5
  7 * Base methods
  8 * 
  9 * @author Photobucket
 10 * @package PBAPI
 11 * @subpackage Methods
 12 * 
 13 * @copyright Copyright Copyright (c) 2008, Photobucket, Inc.
 14 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
 15 */
 16
 17/**
 18 * Load Methods parent
 19 */
 20require_once dirname(__FILE__) . '/../Methods.php';
 21
 22/**
 23 * Base API methods
 24 *
 25 * @package PBAPI
 26 * @subpackage Methods
 27 */
 28class PBAPI_Methods_base extends PBAPI_Methods
 29{
 30
 31    /**
 32     * Ping
 33     *
 34     * @param array $params (anything)
 35     */
 36    public function ping($params = null)
 37    {
 38        if (! empty($params))
 39            $this->core->_setParamList($params);
 40        $this->core->_setUri('/ping');
 41    }
 42
 43    /**
 44     * Search
 45     *
 46     * @param string $term [optional, default=''] search term, '' for recent
 47     * @param array $params array(...)
 48     */
 49    public function search($term = '', $params = null)
 50    {
 51        if (is_array($term) && $params == null)
 52        {
 53            $params = $term;
 54            $term = '';
 55        }
 56        $this->core->_setUri('/search/%s', $term);
 57        if (count($params))
 58            $this->core->_setParamList($params);
 59    }
 60
 61    /**
 62     * Featured Media
 63     *
 64     */
 65    public function featured()
 66    {
 67        $this->core->_setUri('/featured');
 68    }
 69
 70    /**
 71     * User
 72     *
 73     * @param string $username [optional, default=current user token] username
 74     * @param array $params array(...)
 75     */
 76    public function user($username = '', $params = null)
 77    {
 78        if (is_array($username) && $params == null)
 79        {
 80            $params = $username;
 81            $username = '';
 82        }
 83        $this->core->_setUri('/user/%s', $username);
 84        $this->core->_setParamList($params);
 85        
 86        $this->_load('user');
 87    }
 88
 89    /**
 90     * Album
 91     *
 92     * @param string $albumpath album path (username/location)
 93     * @param array $params array(...)
 94     */
 95    public function album($albumpath, $params = null)
 96    {
 97        if (! $albumpath)
 98            throw new PBAPI_Exception('albumpath required', $this->core);
 99        
100        $this->core->_setUri('/album/%s', $albumpath);
101        $this->core->_setParamList($params);
102        
103        $this->_load('album');
104    }
105
106    /**
107     * GroupAlbum
108     *
109     * @param string $grouppath groupalbum path (grouphash/location)
110     * @param array $params array(...)
111     */
112    public function group($grouppath, $params = null)
113    {
114        if (! $grouppath)
115            throw new PBAPI_Exception('grouppath required', $this->core);
116        
117        $this->core->_setUri('/group/%s', $grouppath);
118        $this->core->_setParamList($params);
119        
120        $this->_load('group');
121    }
122
123    /**
124     * Media
125     *
126     * @param string $mediaurl media url (http://i384.photobucket.com/albums/v000/username/location/filename.gif)
127     * @param array $params array(...)
128     */
129    public function media($mediaurl, $params = null)
130    {
131        if (! $mediaurl)
132            throw new PBAPI_Exception('mediaurl required', $this->core);
133        
134        $this->core->_setUri('/media/%s', $mediaurl);
135        $this->core->_setParamList($params);
136        
137        $this->_load('media');
138    }
139
140    /**
141     * Login
142     *
143     * @param string $step [request|access] step of web login/auth process
144     * @param array $params array(...)
145     */
146    public function login($step, $params = null)
147    {
148        if (! $step)
149            throw new PBAPI_Exception('step required', $this->core);
150        
151        $this->core->_setUri('/login/%s', $step);
152        $this->core->_setParamList($params);
153    }
154
155    /**
156     * get accessor tokens 
157     * 
158     * @param array $params array(...)
159     */
160    public function accessor($params = null)
161    {
162        $this->core->_setUri('/accessor');
163        $this->core->_setParamList($params);
164    }
165
166}