Cloudinary\Api::parse_json_response PHP Method

parse_json_response() static public method

static public parse_json_response ( $response )
    static function parse_json_response($response)
    {
        $result = json_decode($response->body, TRUE);
        if ($result == NULL) {
            $error = json_last_error();
            throw new \Cloudinary\Api\GeneralError("Error parsing server response ({$response->responseCode}) - {$response->body}. Got - {$error}");
        }
        return $result;
    }

Usage Example

Example #1
0
 function __construct($response)
 {
     parent::__construct(\Cloudinary\Api::parse_json_response($response));
     $this->rate_limit_reset_at = strtotime($response->headers["X-FeatureRateLimit-Reset"]);
     $this->rate_limit_allowed = intval($response->headers["X-FeatureRateLimit-Limit"]);
     $this->rate_limit_remaining = intval($response->headers["X-FeatureRateLimit-Remaining"]);
 }