Forum Moderators: buckworks
$ch = curl_init("https://www.nochex.com/nochex.dll/apc/testapc");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 4); // times out after 4s
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); // add POST fields and send to NOCHEX APC to match again
curl_setopt($ch, CURLOPT_REFERER, "http://www.domain.com/nochex.php");
$result = curl_exec($ch); // run the whole process
Dont why the return variable of $result could not get the word for "AUTHORISED" or "DECLINED", it is returning whole HTML for this [nochex.com...]
Actually, I want to get its return words, so that i can do it with matching in condition like e.g if ($result == "AUTHORISED") then take action.
Any expert who have this experiences, please...
Many thanks!
foreach ($_POST as $k=>$v) $p[]="$k=$v";
$fields=implode("&",$p);
$fields = ltrim ($fields, "&");
$header = "POST /nochex.dll/apc/apc HTTP/1.0\r\n";
$header.= "Content-Type: application/x-www-form-urlencoded\r\n";
$header.= "Content-Length: ".strlen($fields)."\r\n\r\n";
$fp = fsockopen ("ssl://www.nochex.com", 443, $errno, $errstr, 10);
if ($fp) {
fputs ($fp, $header.$fields);
while (!feof ($fp))
{
$response = fgets ($fp, 1024); // reponse a single word "AUTHORISED" or "DECLINED"
}
}
fclose($fp);
That $response will be assigned by string for "AUTHORISED" or "DECLINED"
$ch = curl_init("https://www.nochex.com/nochex.dll/apc/apc");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 4); // times out after 4s
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields); // add POST fields and send to NOCHEX APC to match again
curl_setopt($ch, CURLOPT_REFERER, "http://www.domain.com/nochex.php");
$result = curl_exec($ch); // run the whole process
I found it, i can get the $result word for "AUTHORIZED" OR "DECLINE" :)