src/Mremi/UrlShortener/Provider/Wechat/OAuthClient.php
public function getAccessToken()
    {
        $client = new Client(array(
            'base_uri' => 'https://api.weixin.qq.com',
        ));

        $apiRawResponse = $client->get('/cgi-bin/token', array(
            'query' => array(
                'grant_type' => 'client_credential',
                'appid'      => $this->appid,
                'secret'     => $this->appsecret,
            ),
        ));
        $response = json_decode($apiRawResponse->getBody()->getContents());

        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(sprintf(
                'Wecaht returned status code "%s" with message "%s".',
                property_exists($response, 'errcode') ? $response->errcode : '',
                property_exists($response, 'errmsg') ? $response->errmsg : ''
            ));
        }

        return $response->access_token;
    }
public function getAccessToken()
    {
        $client = new Client(array(
            'base_uri' => 'https://api.weixin.qq.com',
        ));

        $apiRawResponse = $client->get('/cgi-bin/token', array(
            'query' => array(
                'grant_type' => 'client_credential',
                'appid'      => $this->appid,
                'secret'     => $this->appsecret,
            ),
        ));
        $response = json_decode($apiRawResponse->getBody()->getContents());

        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(sprintf(
                'Wecaht returned status code "%s" with message "%s".',
                property_exists($response, 'errcode') ? $response->errcode : '',
                property_exists($response, 'errmsg') ? $response->errmsg : ''
            ));
        }

        return $response->access_token;
    }
{@inheritdoc}