Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+9 votes
261 views
in Q2A Core by

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...

Q2A version: 1.8.6
by
It's impossible to help without the web server's error log
by
There is no error in error_log file.
by
moved ago by
–1
please help me....
by
+1
We cannot help you without you providing more information about the error. pupi1985 already requested your error log. If there is none, as you claimed in response to that, it is because you configured your web server to not write an error log. Fix that first.

Please log in or register to answer this question.

...