How to log the cURL calls into a file without using Wireshark to capture packets?

613 views Asked by At

I am using PHP and cURL to send in HTTP request to a REST API. However, I need to validate some data going in/out.

How can I get a copy of the entire request logged into a file?

I have added this line to my request

curl_setopt($ch, CURLOPT_VERBOSE, true);

I am hoping I can get a copy to look like this saves to a log file.

--- 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

How can I capture this data without having to use WireShark? I would think cURL and PHP are advanced enough to allow you to log such a thing.

0

There are 0 answers