/plugin/PBAPI/PBAPI/Response/phpserialize.php
PHP | 61 lines | 19 code | 7 blank | 35 comment | 1 complexity | ac71961bdae941e1efcbc229d51776fb MD5 | raw file
1<?php 2use 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/** 17 * Load Response parent 18 */ 19require_once dirname(__FILE__) . '/../Response.php'; 20/** 21 * Response json format parser 22 * 23 * Requires either the JSON extension, or the Services_JSON class from PEAR 24 * 25 * @package PBAPI 26 * @subpackage Response 27 */ 28class PBAPI_Response_phpserialize extends PBAPI_Response 29{ 30 31 /** 32 * Do JSON parse 33 * 34 * @param string $response_string string to parse 35 * @param bool $onlycontent only return content 'node' 36 * @return array associative array of response data 37 */ 38 public function parse($string, $onlycontent = false) 39 { 40 $result = array(); 41 42 $result = unserialize($string); 43 44 $this->detectException($result); 45 46 if ($onlycontent) 47 return @$result['content']; 48 return $result; 49 } 50 51 /** 52 * Returns optimal format string for given parser 53 * 54 * @return string 55 */ 56 public function getFormat() 57 { 58 return 'phpserialize'; 59 } 60 61}