An API call works on the local, but returns 403 on the live server. This api call requires an API key to be passed by post. The cURL code I tried was as below
$header = array("cache-control: no-cache","Content-Type: application/json");
$url = "https://accept.paymobsolutions.com/api/auth/tokens"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);
The response it gave on the server is as below
<html>
<head><title>403 Forbidden</title></head>
<body bgcolor="white">
<center><h1>403 Forbidden</h1></center>
</body>
</html>
I tried it with
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
And got the same response. Also tried on another server and got the same response. But I got the correct response on an AWS server.
The response I got with the verbose on for debugging on server and local is shown below:
Left is server and right is local.
How do I fix this cURL code to run on the server?