显示curl POST请求标头?有没有办法做到这一点? [英] Show Curl POST Request Headers? Is there a way to do this?

查看:218
本文介绍了显示curl POST请求标头?有没有办法做到这一点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在建立一个Curl web自动化应用程序,并且有一些问题,没有得到我的POST操作的期望的结果,我有一些麻烦,弄清楚如何显示我发送的完整的POST请求),我一直在寻找这个,但一切出现的是响应头,实际上我想要这些,但也请求,我没有在google上找到的任何帖子似乎提到..



我知道我可以使用这样的东西显示curl请求的结果(原谅我,如果我的语法关闭,我已经关闭我的虚拟机用我的ide和代码指向

  $ result = curl($ curl_exect); 

$ b

解决方案

无论如何,我们都非常感谢任何有关如何查看完整标题的建议。您可以通过执行以下操作来查看有关传输的信息:

  curl_setopt($ curl_exect,CURLINFO_HEADER_OUT,true); 



  $ information = curl_getinfo($ curl_exect); 


查看: http://www.php.net/ manual / en / function.curl-getinfo.php


您也可以使用 CURLOPT_HEADER

  curl_setopt($ curl_exect,CURLOPT_HEADER,true); 

$ httpcode = curl_getinfo($ c,CURLINFO_HTTP_CODE);

if($ httpcode == 200){
return true;
}

return false;

这些只是一些使用标题的方法。


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

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

before the request, and

$information = curl_getinfo($curl_exect);

after the request

View: http://www.php.net/manual/en/function.curl-getinfo.php

You can also use the CURLOPT_HEADER in your curl_setopt

curl_setopt($curl_exect, CURLOPT_HEADER, true);

$httpcode = curl_getinfo($c, CURLINFO_HTTP_CODE);

if($httpcode == 200) {
    return true;
}

return false;

These are just some methods of using the headers.

这篇关于显示curl POST请求标头?有没有办法做到这一点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆