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