views:

33

answers:

1

I am integrating a 3rd party module into my site. I read their documention, but I stuck at this line:

"Your script should then do a server-to-server posting to our server. For example: https://www.domain.com:XXXX/gateway..."

What is it? I write a php page with a POST-form:

<form action"https://www.domain.com:XXXX/..." method="post">
...
<input type="submit">

Is it something like that?

Then do a response, let say they send back "result=ok", then I catch the result and do a check whether the result is okay or failed?

I interpret in this way, I dont know if I am doing the correct thing. CAn anyone advice? What is the server-to-server posting?

A: 

A server-to-server posting means that the program running on your server makes an HTTP POST to a gateway running on the vendor's server. The code fragment that you provided is HTML. You will need to have a code fragment in PHP (or some other language) to execute the POST. (If you did it in JavaScript, the post will come from your user's web browser, which is not what you want.)

You want to use the PHP HttpRequest class. Take a look at Example #2 in the PHP Manual, reprinted here:

<?php
$r = new HttpRequest('http://example.com/form.php', HttpRequest::METH_POST);
$r->setOptions(array('cookies' => array('lang' => 'de')));
$r->addPostFields(array('user' => 'mike', 'pass' => 's3c|r3t'));
$r->addPostFile('image', 'profile.jpg', 'image/jpeg');
try {
    echo $r->send()->getBody();
} catch (HttpException $ex) {
    echo $ex;
}
?>
vy32