IVRS Push Call - php



Php

function post_to_url() {
$fields = '';
$url="https://services.mgov.gov.in/PushCallAPI/MakePushCall";

$data = array(
"username" => "",//userid for the services portal
"password" => "", //password fro the services portal
"MobileNumbers" =>"",//Mobile number to be dialed
"voiceCode" =>"",);//Voice for voiceFile available on the services portal

foreach($data as $key => $value) {
$fields .= $key . '=' . urlencode($value) . '&';
}
rtrim($fields, '&');

$post = curl_init();

curl_setopt($post, CURLOPT_SSLVERSION, 6); //forces system to use TLSv1.2 protocol
curl_setopt($post, CURLOPT_URL, $url);
curl_setopt($post, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($post, CURLOPT_POST, count($data));
curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
$result =curl_exec($post);
echo"$result";
if(curl_errno($post))
{
echo 'error:' . curl_error($post);
}
curl_close($post);

}
post_to_url();

?>