I have a small PHP script on Amazon EC2 which is supposed to send the OTP to the mobile number. However, the response we are getting is NULL. Below is my PHP code:
<!DOCTYPE html>
<html>
<body>
<?php
/* initialize an array */
$paytmParams = array();
/* Enter user's 10 digit mobile number */
$paytmParams["phone"] = "1234567890";
/* Enter your client id here */
$paytmParams["clientId"] = "some-user";
/* enter resource scope */
$paytmParams["scope"] = "wallet";
/* enter response type, the value here will be 'token' */
$paytmParams["responseType"] = "Token";
/* prepare JSON string for request */
$post_data = json_encode($paytmParams, JSON_UNESCAPED_SLASHES);
/* for Staging */
$url = "https://accounts-uat.paytm.com/signin/otp";
//$auth = "Basic " . base64_encode("some-user" . ":" . "bWPstgyLRfz71GYtgcAbsx1nSPtCqpL9");
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
//curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: " . $auth));
$response = curl_exec($ch);
if (!$response) {
die(curl_error($ch));
}
$response=json_decode($response,true);
if($response['status']=='SUCCESS')
$responseData=array('success'=>'1', 'data'=>$response,'message'=>" The OTP has been sent to your mobile");
else
$responseData=array('success'=>'0', 'data'=>$response,'message'=>"Oops...We are unable to send the OTP at this moment.");
$userResponse = json_encode($responseData);
print $userResponse;
?>
</body>
</html>
The output that we are receiving for the above script is :
Could not resolve host: accounts.paytm.com
However, with the same parameters on Postman, the OTP is received correctly. I think I have set up the server correctly - apache, PHP. I am pretty new to server-side scripting so am not sure what is causing the issue. My guess is there is some configuration issue on the server. Please help me in resolving the issue. Thanks for your help in advance.