Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

khatran's avatar

Can't change senderID in MSG91 with Laravel

I have a project which send SMS from web to mobile. I use MSG91 with this code:

public function sendOtp(Request $request){
$random = rand(100000,999999);
            $getFirstNumber = substr($request->phone,1,9);
            $mobile = "84".$getFirstNumber;
            $url="http://world.msg91.com/api/sendhttp.php?authkey=YourAuthKey&mobiles=".$mobile."&message=".$random."&sender=STBDID&route=4&country=84&campaign=STBDID";
            $postData = array(
                'authkey' => "YourAuthKey",
                'mobile' => $mobile,
                'message' => $random,
                'sender' => "STBDID",
                'country' => 84,
                'route' => "4",
                'campaign'=>"STBDID"
            );
            $paramArr['url'] = $url;
            $paramArr['postData'] = $postData;
            $msg91 = new MSG91;
            $msg91->sendRequest($paramArr);
            return $postData['message'];
}

App\MSG91:

function __construct() {

    }

    public static function sendRequest($param){
        $url = $param['url'];
        $postData = $param['postData'];
    
        $ch = curl_init();
        curl_setopt_array($ch, array(
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_POST => true,
            CURLOPT_POSTFIELDS => $postData
            //,CURLOPT_FOLLOWLOCATION => true
        ));
    
    
        //Ignore SSL certificate verification
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    
    
        //get response
        $output = curl_exec($ch);
    
        //Print error if any
        if(curl_errno($ch))
        {
            return curl_error($ch);
        }
    
        curl_close($ch);
    
        return $output;
    }

SMS is sent to phone. However it show sender name is "VietID"? And message is "..... la ma kich hoat so dien thoai cua ban". Why? So, how do I change senderID or message? I am Vietnamese. Thank you very much! :(

0 likes
1 reply

Please or to participate in this conversation.