为了账号安全,请及时绑定邮箱和手机立即绑定

php curl post json Could not resolve host

php curl post json Could not resolve host

PHP
慕妹3146593 2019-02-27 08:05:35
1.在linux下通过curl直接请求ok2.把代码里面的地址换成ip,请求正常3.代码如下:private function post($url, $data, $timeout = 3)     {         $jsonData = json_encode($data);         $ch = curl_init();         curl_setopt($ch, CURLOPT_URL, $url);         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);         curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);         curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json;Charset=utf-8','Content-Length :'.strlen($jsonData)]);         curl_setopt($ch, CURLOPT_POST, 1);         curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);         $resp = curl_exec($ch);        if ($resp === false) {             Yii::info('resp err:'.curl_error($ch));             curl_close($ch);            return [];         }         curl_close($ch);        return json_decode($resp, true);     }研究了半天,不知道哪有问题,一直无法解析域名。服务器是阿里云的,对方服务器是腾讯云.哪位大神指导一下。
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 474 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信