saad saad - 1 year ago 310
reST (reStructuredText) Question

Payfort REST POST request using JSON

Working on the payfort payment api
I have got a problem with REST POST request using JSON after tokinization is performed. my code is

$service_url = '';
$curl = curl_init($service_url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestParams);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($requestParams)));
$curl_response = curl_exec($curl);

$curl_response is always false

enter image description here

Answer Source

This one give the result

        $requestParams['signature'] = $signature;

        $result = file_get_contents('', null, stream_context_create(array(
                'http' => array(
                'method' => 'POST',
                'header' => 'Content-Type: application/json' . "\r\n"
                . 'Content-Length: ' . strlen($requestParams) . "\r\n",
                'content' => $requestParams,

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download