<?php


function sendSms($cont,$msg){


            $api_key = "b6nXpLJi87My4avjNSoq5cGW1gKVHtxIOEDkmCZrUelFwzY0fhP9TBQ2dRAu3s";
            $shortcode = "Tilil";
            $serviceId = '0';
            //$mobile = "0715745434";
            $mobile = $cont;
            $message = $msg;
            $smsdata = array(
            "api_key" => $api_key,
            "shortcode" => $shortcode,
            "mobile" => $mobile,
            "message" => $message,
            "serviceId" => $serviceId,
            "response_type" => "json",
            );
            $smsdata_string = json_encode($smsdata);
            echo $smsdata_string . "\n";
            $smsURL = "https://api.tililtech.com/sms/v3/sendsms";
            //POST
            $ch = curl_init($smsURL);
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $smsdata_string);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Content-Type: application/json',
            'Content-Length: ' . strlen($smsdata_string))
            );
            $apiresult = curl_exec($ch);
            echo("API Response: $apiresult\n");
                
            // for ($x=156; $x<160; $x++){
            // echo $apiresult['API Response'][$x];
            // }
            if (!$apiresult) {
            die("ERROR on URL[$urls] | error[" . curl_error($ch) . "] | error code[" . curl_errno($ch) . "]\n");
        }  
    }
?>
