【发布时间】: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