0

I want to post some data to the url. Here is my code:

<?php
// registering cookie files
$tmpfname = tempnam("/tmp", "FOO");
$handle = fopen($tmpfname, "w");
fwrite($handle, '');
fclose($handle);
// end registring

function posttoscript($url,$data)
{
global $tmpfname;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_COOKIEJAR, $tmpfname);
curl_setopt($ch, CURLOPT_COOKIEFILE, $tmpfname);
curl_setopt($ch, CURLOPT_REFERER, 'http://azericard.com/pay/index.php');
$response = curl_exec($ch);
return $response;
}

    $data['lang'] = 'az';
    $data['AMOUNT'] = '1';
    $data['CURRENCY'] = 'AZN';
    $data['ORDER'] = '0000659';
    $data['DESC'] = 'Payment for account number 338810194429';
    $data['MERCH_NAME'] = 'International Bank Of Azerbaijan';
    $data['MERCH_URL'] = 'http://www.ibar.az';
    $data['TERMINAL'] = '17200765606';
    $data['EMAIL'] = 'none';
    $data['TRTYPE'] = '0';
    $data['COUNTRY'] = 'AZ';
    $data['MERCH_GMT'] = '+4';
    $data['LANG'] = 'az';
    $data['PAYMENT_TEXT'] = '';
    $data['TIMESTAMP'] = '659695656';
    $data['NONCE'] = 'eiowfhefio';
    $data['BACKREF'] = 'http://ibabankpayment.3dsecure.az/Backref.php';
    $data['P_SIGN'] = '645d65dw6';
$url = 'https://mpi.3dsecure.az/cgi-bin/cgi_link';
$page = posttoscript($url,$data);
echo $page;
?>

But it returns nothing. Normally it must return me a payment page. So when I tried this code i got nothing. There is no any errors to fix it.

Aliyev Rauf
  • 11
  • 1
  • 6
  • basic debugging: curl-exec returns false on failure, so add in a `if ($response === false) { die(curl_error($ch));}` and see what comes out. – Marc B Feb 06 '15 at 18:48
  • I got this error: SSL certificate problem: unable to get local issuer certificate – Aliyev Rauf Feb 06 '15 at 18:50

0 Answers0