POSTMAN 和 PHP CURL for Text-raw with -L options 命令
POSTMAN and PHP CURL for Text-raw with -L options command
我有一个简单的命令可以使用“原始文本”在我的邮递员身上执行,以从 API 获取信息,这样我就可以继续将它与 php 上的 CURL 函数一起使用,除了该命令向我显示错误
“{"message":"'fef229d3bebeedf618cfe2eea6b3233158e65cb349dc200586af334898c792f60c2f12ce07174fed2d07a68b87cd6c7912b5a480a367facc482bd66872c595bfd1a917beedb210315a94fe172a9581354cdea3cf12bcc6c49c80f756f3da4e310a7f242efb9566e5af276d341d4eca48d4d8f93c1f27bc4ee2a056e940125ea7' not a valid key=value pair (missing equal-sign) in Authorization header: 'Bearer fef229d3bebeedf618cfe2eea6b3233158e65cb349dc200586af334898c792f60c2f12ce07174fed2d07a68b87cd6c7912b5a480a367facc482bd66872c595bfd1a917beedb210315a94fe172a9581354cdea3cf12bcc6c49c80f756f3da4e310a7f242efb9566e5af276d341d4eca48d4d8f93c1f27bc4ee2a056e940125ea7'.”}"
所以我不知道问题到底出在哪里我给你看命令:
curl 'https://api.example.com/x/t' \
-H "Authorization: Bearer <PARTNER_ACCESS_TOKEN>" \
-L
我可以看到适合 CURLOPT_HTTPHEADER 的 -H,但是
-L 不知道是什么功能?有人可以帮助我吗?
问题解决:
- 首先:运行 带有 Postman Text-raw (GET) 的命令
- 第二个:-L 选项 Curl 的函数 PHP*
谢谢
可以直接使用curl导入postman:
只需单击导入>原始文本并粘贴 curl 命令。现在点击继续,然后点击导入
什么是-L:
你给出的 curl 不是 curl PHP 它是常规的 php 而 -L 是位置
https://curl.se/docs/manpage.html#-L
-L, --location
(HTTP) If the server reports that the requested page has moved to a
different location (indicated with a Location: header and a 3XX
response code), this option will make curl redo the request on the new
place. If used together with -i, --include or -I, --head, headers from
all requested pages will be shown. When authentication is used, curl
only sends its credentials to the initial host. If a redirect takes
curl to a different host, it won't be able to intercept the
user+password. See also --location-trusted on how to change this. You
can limit the amount of redirects to follow by using the --max-redirs
option.
When curl follows a redirect and if the request is a POST, it will do
the following request with a GET if the HTTP response was 301, 302, or
303. If the response code was any other 3xx code, curl will re-send the following request using the same unmodified method.
You can tell curl to not change POST requests to GET after a 30x
response by using the dedicated options for that: --post301, --post302
and --post303.
The method set with -X, --request overrides the method curl would
otherwise select to use
邮递员尝试:
我用另一个 API Soft“Insomnia”尝试了命令,我的命令有效,所以我不知道为什么使用 POSTMAN 请求获得状态“[=12=” ]403 禁止
这是从POSTMAN导入curl Raw-text后显示的错误
我有一个简单的命令可以使用“原始文本”在我的邮递员身上执行,以从 API 获取信息,这样我就可以继续将它与 php 上的 CURL 函数一起使用,除了该命令向我显示错误
“{"message":"'fef229d3bebeedf618cfe2eea6b3233158e65cb349dc200586af334898c792f60c2f12ce07174fed2d07a68b87cd6c7912b5a480a367facc482bd66872c595bfd1a917beedb210315a94fe172a9581354cdea3cf12bcc6c49c80f756f3da4e310a7f242efb9566e5af276d341d4eca48d4d8f93c1f27bc4ee2a056e940125ea7' not a valid key=value pair (missing equal-sign) in Authorization header: 'Bearer fef229d3bebeedf618cfe2eea6b3233158e65cb349dc200586af334898c792f60c2f12ce07174fed2d07a68b87cd6c7912b5a480a367facc482bd66872c595bfd1a917beedb210315a94fe172a9581354cdea3cf12bcc6c49c80f756f3da4e310a7f242efb9566e5af276d341d4eca48d4d8f93c1f27bc4ee2a056e940125ea7'.”}"
所以我不知道问题到底出在哪里我给你看命令:
curl 'https://api.example.com/x/t' \
-H "Authorization: Bearer <PARTNER_ACCESS_TOKEN>" \
-L
我可以看到适合 CURLOPT_HTTPHEADER 的 -H,但是 -L 不知道是什么功能?有人可以帮助我吗?
问题解决:
- 首先:运行 带有 Postman Text-raw (GET) 的命令
- 第二个:-L 选项 Curl 的函数 PHP* 谢谢
可以直接使用curl导入postman:
只需单击导入>原始文本并粘贴 curl 命令。现在点击继续,然后点击导入
什么是-L: 你给出的 curl 不是 curl PHP 它是常规的 php 而 -L 是位置
https://curl.se/docs/manpage.html#-L
-L, --location
(HTTP) If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will make curl redo the request on the new place. If used together with -i, --include or -I, --head, headers from all requested pages will be shown. When authentication is used, curl only sends its credentials to the initial host. If a redirect takes curl to a different host, it won't be able to intercept the user+password. See also --location-trusted on how to change this. You can limit the amount of redirects to follow by using the --max-redirs option.
When curl follows a redirect and if the request is a POST, it will do the following request with a GET if the HTTP response was 301, 302, or 303. If the response code was any other 3xx code, curl will re-send the following request using the same unmodified method.
You can tell curl to not change POST requests to GET after a 30x response by using the dedicated options for that: --post301, --post302 and --post303.
The method set with -X, --request overrides the method curl would otherwise select to use
邮递员尝试:
我用另一个 API Soft“Insomnia”尝试了命令,我的命令有效,所以我不知道为什么使用 POSTMAN 请求获得状态“[=12=” ]403 禁止
这是从POSTMAN导入curl Raw-text后显示的错误