private function validate($apiRawResponse)
    {
        $response = json_decode($apiRawResponse);

        if (null === $response) {
            throw new InvalidApiResponseException('Sina response is probably mal-formed because cannot be json-decoded.');
        }

        if (property_exists($response, 'error')) {
            throw new InvalidApiResponseException(sprintf(
                'Sina returned status code "%s" with message "%s".',
                property_exists($response, 'error_code') ? $response->error_code : '',
                property_exists($response, 'error') ? $response->error : ''
            ));
        }

        if (property_exists($response, 'urls')) {
            if (empty($response->urls[0]->url_long)) {
                throw new InvalidApiResponseException('Property "longUrl" does not exist within Sina response.');
            }
        }

        return $response;
    }
private function validate($apiRawResponse)
    {
        $response = json_decode($apiRawResponse);

        if (null === $response) {
            throw new InvalidApiResponseException('Sina response is probably mal-formed because cannot be json-decoded.');
        }

        if (property_exists($response, 'error')) {
            throw new InvalidApiResponseException(sprintf(
                'Sina returned status code "%s" with message "%s".',
                property_exists($response, 'error_code') ? $response->error_code : '',
                property_exists($response, 'error') ? $response->error : ''
            ));
        }

        if (property_exists($response, 'urls')) {
            if (empty($response->urls[0]->url_long)) {
                throw new InvalidApiResponseException('Property "longUrl" does not exist within Sina response.');
            }
        }

        return $response;
    }
private function validate ( $ apiRawResponse ) { $ response = json_decode ( $ apiRawResponse ) ; if ( null === $ response ) { throw new InvalidApiResponseException ( 'Sina response is probably mal-formed because cannot be json-decoded.' ) ; } if ( property_exists ( $ response , 'error' ) ) { throw new InvalidApiResponseException ( sprintf ( 'Sina returned status code "%s" with message "%s".' , property_exists ( $ response , 'error_code' ) ? $ response -> error_code : '' , property_exists ( $ response , 'error' ) ? $ response -> error : '' ) ) ; } if ( property_exists ( $ response , 'urls' ) ) { if ( empty ( $ response -> urls [ 0 ] -> url_long ) ) { throw new InvalidApiResponseException ( 'Property "longUrl" does not exist within Sina response.' ) ; } } return $ response ; }
Validates the Sina's response and returns it whether the status code is 200.

@param string $apiRawResponse An API response, as it returned

@return object

@throws InvalidApiResponseException
Validates the Sina s response and returns it whether the status code is 200 .