Favorite.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: Favorite.php 29721 2012-04-26 07:01:08Z zhengqingpeng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. Cloud::loadFile('Service_Client_Restful');
  12. class Cloud_Service_Client_Favorite extends Cloud_Service_Client_Restful {
  13. protected static $_instance;
  14. public static function getInstance($debug = false) {
  15. if (!(self::$_instance instanceof self)) {
  16. self::$_instance = new self($debug);
  17. }
  18. return self::$_instance;
  19. }
  20. public function __construct($debug = false) {
  21. return parent::__construct($debug);
  22. }
  23. public function add($siteUid, $pkId, $id, $idType, $title, $description, $dateline) {
  24. $_params = array(
  25. 'openid' => $this->getUserOpenId($siteUid),
  26. 'sSiteUid' => $siteUid,
  27. 'pkId' => $pkId,
  28. 'fromId' => $id,
  29. 'fromIdType' => $idType,
  30. 'title' => $title,
  31. 'description' => $description,
  32. 'dateline' => $dateline,
  33. 'deviceToken' => $this->getUserDeviceToken($siteUid)
  34. );
  35. return $this->_callMethod('connect.discuz.favorite.add', $_params);
  36. }
  37. public function remove($siteUid, $pkIds, $dateline) {
  38. $_params = array(
  39. 'openid' => $this->getUserOpenId($siteUid),
  40. 'sSiteUid' => $siteUid,
  41. 'pkIds' => $pkIds,
  42. 'dateline' => $dateline
  43. );
  44. return $this->_callMethod('connect.discuz.favorite.remove', $_params);
  45. }
  46. protected function _callMethod($method, $args) {
  47. try {
  48. return parent::_callMethod($method, $args);
  49. } catch (Exception $e) {
  50. }
  51. }
  52. }