【问题标题】:Failed to connect to us15.api.mailchimp.com port 443: Timed out无法连接到 us15.api.mailchimp.com 端口 443:超时
【发布时间】:2018-04-11 03:08:16
【问题描述】:

我有时会使用 mailchimp api 来获取我的 wordpress 主题中的记录

Curl_exec 

正确记录所有记录,但有时不正确,我尝试了所有其他在线可用的建议,例如curl_setopt($ch, CURLOPT_TIMEOUT, 0); 我尝试在最后一个参数中将其设置为 100 400 和 10,但没有成功。我也尝试过其他的东西。

但是当我检查这段代码的错误时

if ( curl_errno( $ch ) ) {
            print curl_error( $ch );
        }

我收到了Failed to connect to us15.api.mailchimp.com port 443: Timed out

寻求完美解决方案的帮助。

private function _raw_request($method, $args=array())
{      
    $args['apikey'] = $this->api_key;
    $url = $this->api_endpoint.'/'.$method.'.json';

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    curl_setopt($ch, CURLOPT_USERAGENT, 'PHP-MCAPI/2.0');       
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_TIMEOUT, 0);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verify_ssl);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($args));
    $result = curl_exec($ch);

    if ( curl_errno( $ch ) ) {
            print curl_error( $ch );
        }


        curl_close($ch);

【问题讨论】:

    标签: php wordpress curl mailchimp-api-v3.0


    【解决方案1】:

    如果您以 HTTPS 模式调用 你必须添加那些 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); 和 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);

    【讨论】:

      猜你喜欢
      • 2023-02-17
      • 2019-02-02
      • 1970-01-01
      • 1970-01-01
      • 2019-02-12
      • 1970-01-01
      • 1970-01-01
      • 2011-12-03
      相关资源
      最近更新 更多