Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在不使用Wireshark捕获数据包的情况下将cURL调用记录到文件中?_Php_Curl_Logging_Wireshark_Icws - Fatal编程技术网

Php 如何在不使用Wireshark捕获数据包的情况下将cURL调用记录到文件中?

Php 如何在不使用Wireshark捕获数据包的情况下将cURL调用记录到文件中?,php,curl,logging,wireshark,icws,Php,Curl,Logging,Wireshark,Icws,我正在使用PHP和cURL向RESTAPI发送HTTP请求。但是,我需要验证一些输入/输出的数据 如何将整个请求的副本登录到文件中 我已将这一行添加到我的请求中 curl_setopt($ch, CURLOPT_VERBOSE, true); 我希望我能得到一份这样的副本保存到日志文件中 --- START REQUEST POST /icws/3048186002/interactions/3002853105 HTTP/1.1 Host: servername:8018 Accept: *

我正在使用PHP和cURL向RESTAPI发送HTTP请求。但是,我需要验证一些输入/输出的数据

如何将整个请求的副本登录到文件中

我已将这一行添加到我的请求中

curl_setopt($ch, CURLOPT_VERBOSE, true);
我希望我能得到一份这样的副本保存到日志文件中

--- START REQUEST
POST /icws/3048186002/interactions/3002853105 HTTP/1.1
Host: servername:8018
Accept: */*
Cookie: icws_3048186002=64425290-29e5-432a-9ee1-c303cdee1f79
ININ-ICWS-CSRF-Token: WAp3cmF0Y2xpZmZlWBJJQ1dTLUFQSS1jb25uZWN0b3JYJGQwYjhlMWRhLTZlOTktNGIwMC05NGNlLTY5MDdkZjUwOWI5Y1gJMTAuMC40LjE4
ININ-ICWS-Session-ID: 3048186002
Content-Type: application/json
Content-Length: 35

{"attributes":{"logged":1}}
--- END REQUEST


--- START RESPOND
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: 0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Content-Type: application/vnd.inin.icws+JSON; charset=utf-8
Date: Wed, 02 Sep 2015 20:39:26 GMT
Server: HttpPluginHost
Content-Length: 0
--- END RESPOND

如何在不使用WireShark的情况下捕获这些数据?我认为cURL和PHP足够先进,可以让您记录这样的事情。

cURL不提供任何日志工具。但是一些库,比如Guzzle,提供了一种调用外部URL的简单方法。这些库通常提供中间件/订阅者。例如Guzzle支持中间件,您可以在github上找到一个用于monolog的中间件。您考虑过使用T-Shark吗?假设您喜欢Wireshark,但不想使用GUI