印象笔记 PHP 开发包的 OAuth 接口调用失败的问题


解决这个问题需要在 Evernote\Auth\OauthHandler.php 文件里添加“CURLOPT_SSL_VERIFYPEER”参数:

protected function getTemporaryCredentials()
{
    $headers = array();
    $headers['Content-Type'] = 'application/x-www-form-urlencoded';
    $headers['Authorization'] = $this->getAuthorizationHeaderString();

    $arguments = array();

    $handle  = curl_init();     

    curl_setopt_array($handle, array(
        CURLOPT_POST           => true,
        CURLOPT_URL            => $this->getBaseUrl('oauth'),
        CURLOPT_HTTPHEADER     => $this->formatHeaders($headers),
        CURLOPT_POSTFIELDS     => http_build_query($arguments, '', '&'),
        CURLOPT_HEADER         => false,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_SSL_VERIFYPEER => 0 // 支持 SSH
    ));

    $raw = curl_exec($handle);

    # close curl handle
    curl_close($handle);

    $responseBody = $this->getResponseBody($raw);

    parse_str($responseBody, $parts);

    print_r($parts);

    return $parts;
}

前一篇:
后一篇:

发表评论