php 将 POSTMAN 请求转换为 Curl

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/49432735/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 02:45:30  来源:igfitidea点击:

Converting a POSTMAN request to Curl

phpcurlpostman

提问by Coder

I am calling my java webservice (POST request) via POSTMAN in the following manner which works perfectly fine (i.e. I can see my records getting inserted into the database):

我通过 POSTMAN 调用我的 java web 服务(POST 请求),其工作正常(即我可以看到我的记录被插入到数据库中):

enter image description here

在此处输入图片说明

And, here's how the contents inside the Headers(1)tab looks like:

而且,Headers(1)选项卡内的内容如下所示:

enter image description here

在此处输入图片说明

Instead of calling it via POSTMAN, I have to call the same request in PHP using CURL. I am wondering if there's a way to export this command to curlcommand so that I could use it in my PHP code? I have found opposite approach at many places online where someone is asking to convert Curl based request to POSTMAN but couldn't figure out how to do the opposite.

我必须使用 CURL 在 PHP 中调用相同的请求,而不是通过 POSTMAN 调用它。我想知道是否有办法将此命令导出到curl命令以便我可以在我的 PHP 代码中使用它?我在网上的许多地方发现了相反的方法,有人要求将基于 Curl 的请求转换为 POSTMAN,但不知道如何做相反的事情。

Some articles I found for curl to postman

我找到了一些文章,用于 curl 到邮递员

回答by Jose M. González

enter image description here

在此处输入图片说明

You can see the button "Code" in the attached screenshot, press it and you can get your code in many different languages including PHP cURL

您可以在附加的屏幕截图中看到“代码”按钮,按下它,您可以获得多种不同语言的代码,包括 PHP cURL

enter image description here

在此处输入图片说明