显示 Curl POST 请求标头?有没有办法做到这一点? [英] Show Curl POST Request Headers? Is there a way to do this?
问题描述
我正在构建一个 Curl 网络自动化应用程序,但在无法获得我的 POST 操作的预期结果时遇到了一些问题,我在弄清楚如何显示我发送的完整 POST 请求时遇到了一些麻烦(带有标题)),我一直在搜索这个,但出现的一切都是响应头,实际上我也想要这些,但也想要请求,我在谷歌上找到的帖子似乎都没有提到..
I'm building a Curl web automation app and am having some issue with not getting the desired outcome of my POST action, I am having some trouble figuring out how I can show the full POST request I am sending over (with headers), I have been searching on this but everything that comes up is the response headers, actually I want these too but also the request, which none of the posts I find on google seem to mention..
我知道我可以使用这样的东西显示 curl 请求的结果(如果我的语法关闭,请原谅我,我已经用我的 ide 和代码关闭了我的虚拟机以供参考
I know I can display the result of a curl request using something like this (forgive me if my syntax is off, I already shut down my virtual machine with my ide and code to refer to
$result = curl($curl_exect) ;
无论如何,我将不胜感激有关如何查看完整标题的任何建议,谢谢
Anyways, I would greatly appreciate any advice on how to view the full headers, thanks
推荐答案
您可以通过以下方式查看有关转移的信息:
You can see the information regarding the transfer by doing:
curl_setopt($curl_exect, CURLINFO_HEADER_OUT, true);
在请求之前,以及
$information = curl_getinfo($curl_exect);
请求后
查看:http://www.php.net/manual/en/function.curl-getinfo.php
您也可以在 curl_setopt
curl_setopt($curl_exect, CURLOPT_HEADER, true);
$httpcode = curl_getinfo($c, CURLINFO_HTTP_CODE);
return $httpcode == 200;
这些只是使用标题的一些方法.
These are just some methods of using the headers.
这篇关于显示 Curl POST 请求标头?有没有办法做到这一点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!