企业微信开发调用获取用户信息接口会间歇性报Connection timed out 错误。
企业微信开发调用getUserInfo 接口会间歇性报错: Failed to connect to qyapi.weixin.qq.com port 443: Connection timed out不是所有请求都会报错,而是间歇性报错。比如有时候几百次请求中会有三四次报错。目前的临时解决办法是如果有报错就再重新去请求下接口,这样基本能暂时解决问题。请求代码如下:public static function vGet($access_token, $code)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=' . $access_token . '&code=' . $code);
curl_setopt($ch, CURLOPT_POST, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_ACCEPT_ENCODING, "gzip,deflate");
$return_data = curl_exec($ch);
if($return_data === false)
{
\think\facade\Log::write('curl error' . curl_error($ch), 'error');
}
curl_close($ch);
\think\facade\Log::write('getUserInfo' . $return_data, 'debug');
return $return_data;
}