Hi,
I create a new page in my site , in qa_include/pages/vip.php
codes :
<?php
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../../');
exit;
}
...
$result = CallAPI('https://sadad.shaparak.ir/VPG/api/v0/Request/PaymentRequest', $data);
if ($result!=false && $result->ResCode == 0) { ......
and add function CallAPI in end off qa_include/qa-base.php
codes :
function CallAPI($url, $data = false)
{
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json; charset=utf-8'));
curl_setopt($ch, CURLOPT_POST, 1);
if ($data)
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
error_log(print_r("before=".curl_error($ch), true));
$result = curl_exec($ch);
error_log(print_r("after=".curl_error($ch), true));
curl_close($ch);
return !empty($result) ? json_decode($result) : false;
}
catch (Exception $ex) {
return false;
}
}
when user click button "send" after a few second browser gives "500 internal server error".
problem is in "$result = curl_exec($ch);" because error_log "before" happens but after dont happens. i use cpanel and php 7.4.
in PHP 5.6 same error happened too.
The important thing is that I set a timeout of 15 seconds, the first time the user hits the send button, he will get a 500 error, but the second time he hits the send button, no error will be seen.
please help me...