【发布时间】:2017-10-25 01:35:13
【问题描述】:
环境
-
PHP 版本:PHP 5.6.21
-
cURL 版本:curl 7.29.0
-
网络服务器:Nginx
-
Linux : Cent 操作系统
说明
我在 PHP 中有这个 CURL。
$headers = array(
"Content-Type: application/x-www-form-urlencoded",
"Authorization: Basic " . $auth_code
);
$data = 'grant_type=authorization_code&code='.$code;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$AUTH_TOKEN_URL);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 1000);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch, CURLOPT_ENCODING , "gzip");
curl_setopt($ch, CURLOPT_USERAGENT,'php');
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
$info = curl_getinfo($ch);
$result = curl_exec($ch);
我进行了 Wireshark 捕获,我没有发起任何 GET/POST 请求。
什么可以阻止它?
我还应该研究什么?
我试过打印出这两个值
**dd($ch);**
我明白了
"ch" => curl resource @10 ▼
url: "https://www.web.com/oauth"
content_type: null
http_code: 0
header_size: 0
request_size: 0
filetime: -1
ssl_verify_result: 0
redirect_count: 0
total_time: 0.004216
namelookup_time: 0.004148
connect_time: 0.113475
pretransfer_time: 0.0
size_upload: 0.0
size_download: 0.0
speed_download: 0.0
speed_upload: 0.0
download_content_length: -1.0
upload_content_length: -1.0
starttransfer_time: 0.0
redirect_time: 0.0
redirect_url: ""
primary_ip: "8.8.8.8"
certinfo: []
primary_port: 443
local_ip: "10.0.129.127"
local_port: 56907
}
与:
**dd($info);**
我明白了
"info" => array:26 [▼
"url" => "https://www.web.com/oauth"
"content_type" => null
"http_code" => 0
"header_size" => 0
"request_size" => 0
"filetime" => 0
"ssl_verify_result" => 0
"redirect_count" => 0
"total_time" => 0.0
"namelookup_time" => 0.0
"connect_time" => 0.0
"pretransfer_time" => 0.0
"size_upload" => 0.0
"size_download" => 0.0
"speed_download" => 0.0
"speed_upload" => 0.0
"download_content_length" => -1.0
"upload_content_length" => -1.0
"starttransfer_time" => 0.0
"redirect_time" => 0.0
"redirect_url" => ""
"primary_ip" => ""
"certinfo" => []
"primary_port" => 0
"local_ip" => ""
"local_port" => 0
]
那里似乎什么都没有。
【问题讨论】:
-
你检查过网络服务器和系统日志吗?
-
nginx 日志?还是 cent 操作系统日志?
-
在
/var/log/messages或通过journalctl取决于CentOS 的版本。 -
创建一个 PHP INFO 文件 phpinfo.php,其内容位于服务器下方,并将其加载到浏览器中 - 然后在该信息中搜索 curl
<?php phpinfo(); ?> -
Php - Debugging Curl - 您可以将 curl 错误保存到文件中。看
$verbose = ...
标签: php laravel http curl request