/    Sign up×
Community /Pin to ProfileBookmark

Handling http post with php

We’re posting data through http post to our customers. One of our customers want this integration working with php, but they are unable to receive the post.

The connection is not a form-type connection with several parameters (like fields from an html form), but rather a stream where the data is contained in the actual body of the request.

In Java, we read this body like this:

[CODE]BufferedReader br = req.getReader(); //req is the incoming HttpServletRequest
String inputLine;
StringBuffer strBuffMessage = new StringBuffer();

while ((inputLine = br.readLine()) != null) {
strBuffMessage.append(inputLine);
} // while

br.close();[/CODE]

We don’t read any parameters; just the connection body itself.

Can this be solved with php as well?

Regards
Marius Waldal

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@bokehAug 22.2005 — The answer to your question is probably yes. I don't understand the code you posted (not a java person). Can you explain in greater detail. Are you asking if a PHP script can send post data? Or receive it? It can do both but to help you I would need more info.
Copy linkTweet thisAlerts:
@rch10007Aug 23.2005 — Try reading this: http://www.php.net/manual/en/function.extract.php

you can use something like: extract ( $_POST );

This will create NEW variables for every variable in the posted data with the same name as the posted variable.

You said it's streaming data, though, hmmm...

Try reading this too: http://www.php.net/manual/en/ref.stream.php

As Bokeh said, we need more info to help unless someone knows PHP and JAVA - maybe that's what you're hoping for - BONUS!
Copy linkTweet thisAlerts:
@lmwaldalauthorAug 23.2005 — Thanks a lot to bokeh and rch10007 for trying to help, but it seems we solved it in a very simple way! The actual body of the post is contained in

$GLOBALS["HTTP_RAW_POST_DATA"];

This variable contains the XML we sent through the connection, so by only getting the contents here we accomplish what we wanted.

Thanks again for helping.

Marius Waldal
×

Success!

Help @lmwaldal spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...