/plugin/PBAPI/PBAPI/Response/phpserialize.php

https://bitbucket.org/chamilo/chamilo-ext-repo-photobucket-dev/ · PHP · 61 lines · 19 code · 7 blank · 35 comment · 1 complexity · ac71961bdae941e1efcbc229d51776fb MD5 · raw file

  1. <?php
  2. use common\libraries\Path;
  3. /**
  4. * Photobucket API
  5. * Fluent interface for PHP5
  6. * PHP response parser
  7. *
  8. * @author Photobucket
  9. * @package PBAPI
  10. * @subpackage Response
  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 Response parent
  17. */
  18. require_once dirname(__FILE__) . '/../Response.php';
  19. /**
  20. * Response json format parser
  21. *
  22. * Requires either the JSON extension, or the Services_JSON class from PEAR
  23. *
  24. * @package PBAPI
  25. * @subpackage Response
  26. */
  27. class PBAPI_Response_phpserialize extends PBAPI_Response
  28. {
  29. /**
  30. * Do JSON parse
  31. *
  32. * @param string $response_string string to parse
  33. * @param bool $onlycontent only return content 'node'
  34. * @return array associative array of response data
  35. */
  36. public function parse($string, $onlycontent = false)
  37. {
  38. $result = array();
  39. $result = unserialize($string);
  40. $this->detectException($result);
  41. if ($onlycontent)
  42. return @$result['content'];
  43. return $result;
  44. }
  45. /**
  46. * Returns optimal format string for given parser
  47. *
  48. * @return string
  49. */
  50. public function getFormat()
  51. {
  52. return 'phpserialize';
  53. }
  54. }