相关疑难解决方法(0)

在向服务器发送请求时,如何查看curl发出的请求标头?

我希望curl在向服务器发送请求时看到请求标头.我该怎么检查?

curl

454
推荐指数
10
解决办法
41万
查看次数

如何获取有关已发送的PHP curl请求的信息

我正在尝试将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)

php curl web-services

45
推荐指数
2
解决办法
10万
查看次数

标签 统计

curl ×2

php ×1

web-services ×1