This is a discussion on How can I get the message-body ? within the PHP Language forums, part of the PHP Programming Forums category; Hy all In my application I'll receive XML text in the HTTP-message body in a particular format that ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hy all In my application I'll receive XML text in the HTTP-message body in a particular format that only my application understands My script will be requested by the client with HTTP POST and the HTTP request will contain the XML as reqest-message body I couldn't find a way to acces the POST message body in my script to parse the XML and extract my data. I know I can get the request-message headers and I know I can set some of the response-headers. How do I get the HTTP request message body ? My request method is POST and the message body contains the information I need ----------------- Thank you Timothy Madden Romania And I don't wanna miss a thing |
|
|||
|
> How do I get the HTTP request message body ? My request method is POST and
> the message body contains the information I need I have never done anything like that, but imagine for a moment, that there is a form with textarea where users type XML messages. I think that the easiest way to do it ist to have a HTTP POST variable that contains whole xml message. Probably the xml message should be URL encoded. DG |
|
|||
|
On Thu, 22 Jul 2004 16:54:03 +0300, Timothy Madden wrote:
> Hy all > > In my application I'll receive XML text in the HTTP-message body in a > particular format that only my application understands > My script will be requested by the client with HTTP POST and the HTTP > request will contain the XML as reqest-message body > > I couldn't find a way to acces the POST message body in my script to parse > the XML and extract my data. I know I can get the request-message headers > and I know I can set some of the response-headers. > > How do I get the HTTP request message body ? My request method is POST and > the message body contains the information I need > What's hapening, nobody knows ? It can't be that hard ... -- ------------------------------------ Thank you Timothy Madden Romania And I don't wanna miss a thing |
|
|||
|
Hello,
On Thu, 22 Jul 2004 16:54:03 +0300, Timothy Madden wrote: > In my application I'll receive XML text in the HTTP-message body in a > particular format that only my application understands > My script will be requested by the client with HTTP POST and the HTTP > request will contain the XML as reqest-message body > > I couldn't find a way to acces the POST message body in my script to parse > the XML and extract my data. I know I can get the request-message headers > and I know I can set some of the response-headers. > > How do I get the HTTP request message body ? My request method is POST and > the message body contains the information I need You may want to try this HTTP client class that lets you send POST requests with arbitrary body data. It even comes with an example of posting requests with XML body data: http://www.phpclasses.org/httpclient -- Regards, Manuel Lemos PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/ Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html |
|
|||
|
On Fri, 23 Jul 2004 11:51:09 -0300, Manuel Lemos wrote:
> Hello, > > On Thu, 22 Jul 2004 16:54:03 +0300, Timothy Madden wrote: >> In my application I'll receive XML text in the HTTP-message body in a >> particular format that only my application understands >> My script will be requested by the client with HTTP POST and the HTTP >> request will contain the XML as reqest-message body >> >> I couldn't find a way to acces the POST message body in my script to parse >> the XML and extract my data. I know I can get the request-message headers >> and I know I can set some of the response-headers. >> >> How do I get the HTTP request message body ? My request method is POST and >> the message body contains the information I need > > You may want to try this HTTP client class that lets you send POST > requests with arbitrary body data. It even comes with an example of > posting requests with XML body data: > > http://www.phpclasses.org/httpclient No luck :( not what I need -- ------------------------------------ Thank you Timothy Madden Romania And I don't wanna miss a thing |
|
|||
|
Timothy Madden <batman@rmv.spam.home.ro> wrote in message news:<nyyg85vlpi56$.2vlema9zaxac.dlg@40tude.net>.. .
<snip> > How do I get the HTTP request message body ? My request method is POST and > the message body contains the information I need http://in.php.net/curl > ----------------- Your sig-marker is wrong. It should be "-- \n" > Thank you > Timothy Madden > Romania > And I don't wanna miss a thing -- | Just another PHP saint | Email: rrjanbiah-at-Y!com |
|
|||
|
On 26 Jul 2004 21:05:42 -0700, R. Rajesh Jeba Anbiah wrote:
> Timothy Madden <batman@rmv.spam.home.ro> wrote in message news:<nyyg85vlpi56$.2vlema9zaxac.dlg@40tude.net>.. . > <snip> >> How do I get the HTTP request message body ? My request method is POST and >> the message body contains the information I need > > http://in.php.net/curl > Can you please be more specific ? I did not find what I need in there either. I need to get the message-body of the HTTP-request-message that initiated my script, that is the one that requested my URL. Normally such a message is a GET request and doesn't have a message-body. But it can have one anyway and in my case the request message is a POST request. POST requests can carry form-fields values in the message body and if so PHP will automaticaly set up variables with these values. But in my case the request-message-body contains some arbitrary raw data that I need to get. Any help would be apreciated. -- ------------------------------------ Thank you Timothy Madden Romania And I don't wanna miss a thing |
|
|||
|
Timothy Madden <batman@rmv.spam.home.ro> wrote in message news:<1u2la2qxucdp6.fz6qrufli2lb$.dlg@40tude.net>. ..
> On 26 Jul 2004 21:05:42 -0700, R. Rajesh Jeba Anbiah wrote: > > > Timothy Madden <batman@rmv.spam.home.ro> wrote in message news:<nyyg85vlpi56$.2vlema9zaxac.dlg@40tude.net>.. . > > <snip> > >> How do I get the HTTP request message body ? My request method is POST and > >> the message body contains the information I need > > > > http://in.php.net/curl > > > Can you please be more specific ? > > I did not find what I need in there either. > I need to get the message-body of the HTTP-request-message that initiated > my script, that is the one that requested my URL. <snip> Now, I'm totally confused. I'd thought that you want to do POST to some script and get back the message body alone. Could you provide more details like some pseudo-code..? or perhaps you may want to try print_r($GLOBALS) ?? -- | Just another PHP saint | Email: rrjanbiah-at-Y!com |
|
|||
|
On 27 Jul 2004 04:37:46 -0700, R. Rajesh Jeba Anbiah wrote:
> Timothy Madden <batman@rmv.spam.home.ro> wrote in message news:<1u2la2qxucdp6.fz6qrufli2lb$.dlg@40tude.net>. .. >> On 26 Jul 2004 21:05:42 -0700, R. Rajesh Jeba Anbiah wrote: >> >>> Timothy Madden <batman@rmv.spam.home.ro> wrote in message news:<nyyg85vlpi56$.2vlema9zaxac.dlg@40tude.net>.. . >>> <snip> >>>> How do I get the HTTP request message body ? My request method is POST and >>>> the message body contains the information I need <snip> > > Could you provide more details like some pseudo-code..? or perhaps > you may want to try print_r($GLOBALS) ?? Here's how it is: A machine in my intranet, which is not a personal computer, but a SMS gateway, will open a TCP/IP connection on port 80 on my webserver, using regular sockets and will send the following: POST /smschat/dispatch.php HTTP/1.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Length: 250 <xml> <object> <request> <msisdn>0888567987</msisdn> <mcc>040</mcc> <mnc>010</mnc> <body>I have a new SMS</body> </request> </object> And after that the sms-gateway will start to receive data on the connection from the webserver. This is what the sms-gateway does, not me or my script, and is not something that I could easyly change. This just happens. Now I am the author of '/smschat/dispatch.php' script on my webserver. What I want in my php script is to get the body of the message, that is the following: <xml> <object> <request> <msisdn>0888567987</msisdn> <mcc>040</mcc> <mnc>010</mnc> <body>I have a new SMS</body> </request> </object> </xml> Note the value of the Content-Type header is not text/x-wwwform-urlencoded. What do you think ? Anyone has any ideea ? -- ------------------------------------ Thank you Timothy Madden Romania And I don't wanna miss a thing |
|
|||
|
"Timothy Madden" <batman@rmv.spam.home.ro> wrote in message news:ddmr7rz01j6m.1qr0d2u128yjx.dlg@40tude.net... > On 27 Jul 2004 04:37:46 -0700, R. Rajesh Jeba Anbiah wrote: > > > Timothy Madden <batman@rmv.spam.home.ro> wrote in message news:<1u2la2qxucdp6.fz6qrufli2lb$.dlg@40tude.net>. .. > >> On 26 Jul 2004 21:05:42 -0700, R. Rajesh Jeba Anbiah wrote: > >> > >>> Timothy Madden <batman@rmv.spam.home.ro> wrote in message news:<nyyg85vlpi56$.2vlema9zaxac.dlg@40tude.net>.. . > >>> <snip> > >>>> How do I get the HTTP request message body ? My request method is POST and > >>>> the message body contains the information I need > <snip> > > > > Could you provide more details like some pseudo-code..? or perhaps > > you may want to try print_r($GLOBALS) ?? > > Here's how it is: > > A machine in my intranet, which is not a personal computer, but a SMS > gateway, will open a TCP/IP connection on port 80 on my webserver, using > regular sockets and will send the following: > > POST /smschat/dispatch.php HTTP/1.1 > Content-Type: text/plain; charset=ISO-8859-1 > Content-Length: 250 > [snip ... ] > > And after that the sms-gateway will start to receive data on the connection > from the webserver. This is what the sms-gateway does, not me or my script, > and is not something that I could easyly change. This just happens. > > Now I am the author of '/smschat/dispatch.php' script on my webserver. What > I want in my php script is to get the body of the message> > Note the value of the Content-Type header is not text/x-wwwform-urlencoded. > After a few months I found the answer. There is a variable called $HTTP_RAW_POST_DATA available when the Content-Type is not text/x-wwwform-urlencoded and there is also php:://stdin as a file in the special, 'php://', protocol I could use with fopen. Timothy Madden Romania ---------------------------------- And I don't wanna miss a thing |