<?php
 
namespace App\Traits;

trait Sms {
 
   /*
    * Generates text from the number
    */
   public function SendOtpTo($user_mobile){
      
        //  http://bulksms.smsroot.com/app/smsapi/index.php?key=55F927CAF2BCED&campaign=0&routeid=26&type=text&contacts=98012XXXXX&senderid=SJSMTH&msg=Hello+People%2C+have+a+great+day&template_id=9170xxx
         $headers = array("Content-Type:application/json");
         
         $api_key = '55F927CAF2BCED';
         $contacts = $user_mobile;
         $route = "33";//TransAPI ID= 13, TRANS-OTP ID= 33
         $senderId = "TULLYG";
         $otp = rand(1001,9999);
         return 1234;
         $message = "Your verification code is ".$otp." TullyGully";
         $templateid = "1XXXXXXXX0XXXXXXX20";

         $call_url = "http://bulksms.smsroot.com/app/smsapi/index.php?key=".$api_key."&campaign=0&routeid=".$route."&type=text&contacts=".$contacts."&senderid=".$senderId."&msg=".urlencode($message);
        
         // echo $call_url; exit();
         $ch = curl_init();   
         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);   
         curl_setopt($ch, CURLOPT_URL, $call_url);   
           
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);   
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);   
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);   
            
         $response = curl_exec($ch);   
           
         if ($response === FALSE) {   
            die('Curl failed: ' . curl_error($ch));   
         }    
         curl_close($ch);
        //  dd($response);
         //return $response;  
         return $otp;  
         
   }  
   
 
}






