Yii2 短信网关- 短信无法发送

Yii2 sms gateway- Sms is not going

我有短信网关,用于在 Yii2 项目上发送短信。 当我调用存储短信代码的特定操作时,短信不会发送。 如果我打印该短信 url 并在浏览器中复制粘贴并点击它……它会继续。 不知道Yii2有什么问题

下面是动作代码,curl代码在模型

  public function actionMessage() {  
        /*sms code start*/ 
                $model = new BillPersonal();

                $mobile = "9703843454";
                $authKey = "XXXXXXXXXXXXXX";
                $senderId = "XXXXXX";
                $textMessage = "Test Messsage"; 

                $url = sprintf("http://www.smsgatewayhub.com/api/mt/SendSMS?APIKey=".$authKey."&senderid=".$senderId."&channel=2&DCS=0&flashsms=0&number=91".$mobile."&text=".$textMessage."&route=11"); 

                $curl_handle = curl_init();
                      curl_setopt($curl_handle, CURLOPT_URL, $url);
                      curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 5);
                      curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
                      curl_setopt($curl_handle, CURLOPT_USERAGENT, 'CHMS');
                      $query = curl_exec($curl_handle);
       }

我终于找到了解决方案。问题出在 CURL 设置上。希望这对某人有所帮助。

public function actionSms(){

               $apikey = "XXXXXXXXXXXXXXXXXXX";
               $apisender = "XXXXXXXXX";
               $msg ="YOUR MESSAGE";
               $num = "91XXXXXXXXXXXX";     

               $ms = rawurlencode($msg);   

            $url = 'https://www.smsgatewayhub.com/api/mt/SendSMS?APIKey='.$apikey.'&senderid='.$apisender.'&channel=2&DCS=0&flashsms=0&number='.$num.'&text='.$ms.'&route=1';

             //echo $url;
             $ch=curl_init($url);
             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
             curl_setopt($ch,CURLOPT_POST,1);
             curl_setopt($ch,CURLOPT_POSTFIELDS,"");
             curl_setopt($ch, CURLOPT_RETURNTRANSFER,2);
             $data = curl_exec($ch);
             echo '<br/><br/>';
             print($data); /* result of API call*/
      }