我正在尝试将curl请求调试到webservice'getToken'端点.
我并不是100%确信URL和身份验证信息正确地写入了卷曲句柄.
我正在尝试curl_getinfo($ch, CURLINFO_HEADER_OUT);捕获已发送的请求,但它并没有给我太多信息.有没有办法更深入地诊断实际的卷曲请求是什么样的?
这是代码:
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HEADER, 1); // just getting header to see if we got an auth token
curl_setopt($ch, CURLOPT_FILE, $fh);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLINFO_HEADER_OUT, 1); // capture the header info
curl_setopt($ch, CURLOPT_VERBOSE, 1); // turn verbose on
// execute the curl request
$rh = fopen("request.txt", "w"); // open request file handle
$verbose = fopen('php://temp', 'rw+');
curl_setopt($ch, CURLOPT_STDERR, $verbose);
curl_exec($ch); // execute request
$sent_request = curl_getinfo($ch, …Run Code Online (Sandbox Code Playgroud)