$ _POST方法中的Url PUSH问题

$ _POST方法中的Url PUSH问题

问题描述:

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

目前我一直致力于一个连接到smsgateway的项目。 一旦用户将短信发送到网关,它就会将请求重定向到我们的服务器。 问题是它们是在$ _GET方法中收到的。 但是短信提供商说他们用$ _POST方法传递它。 我们收到的网址如下所示。 p>

http://www.example.com/smstest?msg=sample&id=55788 p>

当您使用$ _POST时,是否可以在网址中接收参数 方法 p> div>

You can only have one verb (POST, GET, PUT, ...) when doing an HTTP Request. However, you can do

<form name="y" method="post" action"y.php?foo=bar">

and then PHP will populate $_GET['foo'] as well, although the Request was POST'ed.

For comment

By using

$_SERVER['REQUEST_METHOD']

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.

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 as GET (and PUT and DELETE). A URL can always contain query parameters and it can also always contain a request body (though GET 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.