raphael232
Programmer
Hi, a recent client has requested to use a payment provider i have not used before. I have checked their documentation but all their examples are in php.
Here is the code in their example:
I'm not too familiar with php and would appreciate if someone could explain to me what this is doin and an point me in the direction of an alternative in asp.
Thanks
Here is the code in their example:
Code:
$poststring = "<?xml version='1.0' encoding='UTF-8'?>....................";
$fp = fsockopen("ssl://".$host, $port, $errno, $errstr, 5);
if(!$fp){
//error; tell us
echo "Error: $errstr ($errno)\n";
}else{
//send the server request
fputs($fp, "POST $path HTTP/1.0\r\n");
/////////////////////////////////////////////////////////////////////////
// if problem with php 5 use instead
/////////////////////////////////////////////////////////////////////////
// fputs($fp, "POST $path HTTP/1.0\r\n");
/////////////////////////////////////////////////////////////////////////
fputs($fp, "Host: $host\r\n");
fputs($fp,"Content-type: text/xml\r\n");
fputs($fp, "Content-length: ".strlen($poststring)."\r\n");
fputs($fp, "Authorization: Basic ".base64_encode($login.":".$pass."\r\n"));
fputs($fp, "Connection: close\r\n");
fputs($fp,"\r\n");
fputs($fp, $poststring . "\r\n\r\n");
// prepare for reading the response
stream_set_timeout($fp,5);
// here we save the response body - XML response from WireCard
$output = "";
// here we store the HTTP headers
$headers= "";
// temp. variable for detecting the end of HTTP headers.
$is_header = 1;
while(!feof($fp)) {
$buffer = fgets($fp, 128);
// fgets on SSL socket
if ($buffer == FALSE) {
break;
}
if (!$is_header) {
$output .= $buffer;
}
if ($buffer == "\r\n") {
$is_header = 0;
}
if ($is_header) {
$headers .= $buffer;
}
}
//close fp - we are done with it
fclose($fp);
// print the results in Web Browser - and convert all special
// characters (like <,>,...) to HTML entities
echo "<PRE>\n";
echo htmlentities($headers);
echo "\n";
echo htmlentities($output);
echo "</PRE>\n";
}
I'm not too familiar with php and would appreciate if someone could explain to me what this is doin and an point me in the direction of an alternative in asp.
Thanks