<?php

defined('BASEPATH') or exit('No direct script access allowed');



class Sms_send

{
        /* ------------ SMS sending by BrandSMS---------------- */

        function send_sms($number, $msg)
        {

        /* number */

            $num = "880" . $number;

        /* generated api key */

            // $API_key = "44515923723422791592372342";
            $API_key = "44516920093905521692009390";

        /* sms type (unicode for bangla)*/

            $type = "text";

        /* admin user ID */

            $id = "01844532635";

            $data = array(
                "api_key" => $API_key,
                "type" => $type,
                "contacts" => $num,
                "senderid" => $id,
                "msg" => $msg
            );

    

        //$url = "http://brandsms.mimsms.com/smsapi?api_key='$API_key'&type='$type'&contacts='$num'&senderid='$id'&msg='$msg'";
       
            $url = "http://sms.ctghostbd.com/api/v1/send?";
			//$url = "http://sms.biz-bazar.com/api/v1/send";
            $ch = curl_init();

            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
            curl_setopt($ch, CURLOPT_POST, 1);

            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);

            curl_setopt($ch, CURLOPT_TIMEOUT, 60);


        // This should be the default Content-type for POST requests

        //curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: application/x-www-form-urlencoded"));



            $result = curl_exec($ch);

            if (curl_errno($ch) !== 0) {

                error_log('cURL error when connecting to ' . $url . ': ' . curl_error($ch));

            }

            curl_close($ch); 

        }



}