$_POST 方法中的 URL PUSH 问题
目前我一直在开发一个连接到短信网关的项目。一旦用户向网关发送短信,它就会将请求重定向到我们的服务器。问题是它们是通过 $_GET 方法接收的。但短信提供商表示他们正在 $_POST 方法中传递它。我们最后收到的 URL 如下所示。
http://www.example.com/smstest?msg=sample&id=55788
使用$_POST方法是否可以接收url中的参数
Currently i have been working on a project which connects to a smsgateway. Once the user sends sms to gateway it redirects the requests to our server. Problem is they are received in $_GET method. But the sms provider says they are passing it in $_POST method. Url received at our end looks like the following.
http://www.example.com/smstest?msg=sample&id=55788
Is it possible to receive parameters in url when you use the $_POST method
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
HTTP 请求可以使用 HTTP 方法
POST
并且仍然使用包含查询参数的 URL。POST
只是 HTTP 标头中使用的“动词”,与GET
相同(以及PUT
和DELETE
)。 URL 始终可以包含查询参数,也可以始终包含请求正文(尽管GET
请求不应该)。 PHP 变量$_GET
仅表示已解析的 URL 查询参数,变量$_POST
仅表示已解析的请求正文。它们实际上与 HTTP 动词没有任何关系,因此有些命名错误。An HTTP request can use the HTTP method
POST
and still use a URL that contains query parameters.POST
is just a "verb" used in the HTTP header, the same asGET
(andPUT
andDELETE
). A URL can always contain query parameters and it can also always contain a request body (thoughGET
requests shouldn't). The PHP variable$_GET
simply represents the parsed URL query parameters, the variable$_POST
simply represents the parsed request body. They do not actually have anything to do with the HTTP verb and are therefore somewhat misnamed.是的。每个 HTTP 请求的第一行包含 方法(或动词)和发出请求的 URI。根据方法的选择,对 URI 没有特殊限制,因此可以对包含
在 PHP 中,您通常可以通过
$_GET
和$_REQUEST
访问查询字符串中的参数。作为提交表单的一部分传递的参数一如既往地可以通过$_POST
和$_REQUEST
访问。Yes, it is. The first line of every HTTP request contains the method (or verb) and the URI for which the request is made. No special restrictions are placed on the URI based on the choice of method, so POST requests may be made for a URI that includes a query string.
From PHP you can access the parameters in the query string normally through
$_GET
and$_REQUEST
. Parameters passed as part of a submitted form are accessible as always through$_POST
and$_REQUEST
.只能有一个动词 (POST, GET, PUT, ...) 执行HTTP 请求时。但是,您可以这样做
,然后 PHP 也会填充 $_GET['foo'],尽管请求是 POST 的。
发表评论
通过使用
You can only have one verb (POST, GET, PUT, ...) when doing an HTTP Request. However, you can do
and then PHP will populate $_GET['foo'] as well, although the Request was POST'ed.
For comment
By using