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

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

        if (!property_exists($response, 'errcode')) {
            throw new InvalidApiResponseException('Property "errcode" does not exist within Wechat response.');
        }

        if (0 !== $response->errcode) {
            throw new InvalidApiResponseException(sprintf('Wechat returned status code "%s" with message "%s"',
                $response->errcode,
                property_exists($response, 'errmsg') ? $response->errmsg : ''
            ));
        }

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

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

        if (!property_exists($response, 'errcode')) {
            throw new InvalidApiResponseException('Property "errcode" does not exist within Wechat response.');
        }

        if (0 !== $response->errcode) {
            throw new InvalidApiResponseException(sprintf('Wechat returned status code "%s" with message "%s"',
                $response->errcode,
                property_exists($response, 'errmsg') ? $response->errmsg : ''
            ));
        }

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

@param string $apiRawResponse

@return object

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