【问题标题】:Sending SMS via PHP Codeigniter and email-to-SMS gateway通过 PHP Codeigniter 和电子邮件到短信网关发送短信
【发布时间】:2012-03-11 20:43:50
【问题描述】:

我正在尝试通过 PHP Codeigniter 中的以下内容发送短信。

如果我从我的 gmail 客户端向同一“##########@vtext.com”发送电子邮件,我会收到短信。

如果我使用下面的相同代码但替换我的 gmail 帐户,我会通过电子邮件收到消息。

但是,我似乎无法触发通过以下代码发送给我的短信。

我认为这可能与电话服务中某处的垃圾邮件过滤器有关。

任何建议,或者通过 PHP/Codeigniter 发送 SMS 的免费解决方法?谢谢!

public function textMe()
    {
        $this->load->library('email'); 
        $this->email->to('##########@vtext.com'); [number edited out]
        $this->email->from('Notify@test.org','Test'); 
        $this->email->subject("Test Subject"); 
        $this->email->message('Test Message'); 
        $this->email->send(); 
        echo $this->email->print_debugger();
    }

【问题讨论】:

    标签: codeigniter sms


    【解决方案1】:

    Codeigniter 助手在这种情况下很有用。辅助功能将在需要时可用。将以下文件保存在 Application/Heplers/sendsms_helper.php

     /*Start sendsms_helper.php file */
    
        function sendsms($number, $message_body, $return = '0'){       
            $sender = 'SEDEMO';  // Need to change
            $smsGatewayUrl = 'http://springedge.com';
            $apikey = '62q3z3hs49xxxxxx'; // Change   
    
            $textmessage = urlencode($textmessage);
            $api_element = '/api/web/send/';
            $api_params = $api_element.'?apikey='.$apikey.'&sender='.$sender.'&to='.$mobileno.
    '&message='.$textmessage;    
            $smsgatewaydata = $smsGatewayUrl.$api_params;
            $url = $smsgatewaydata;
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_POST, false);
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $output = curl_exec($ch);
            curl_close($ch);        
            if(!$output){
               $output =  file_get_contents($smsgatewaydata);
            }
    
            if($return == '1'){
                return $output;            
            }else{
                echo "Sent";
            }        
        }
    
        /*     * End sendsms_helper.php file     */
    
    • ** 使用:**
        1. 加载 sendms 帮助程序为 $this->load->helper('sendsms_helper');
        1. 调用 sendms 函数 例如。 sendsms( '919918xxxxxx', '测试消息' );

    【讨论】:

      猜你喜欢
      • 2011-02-01
      • 2011-05-18
      • 2017-02-03
      • 2011-03-30
      • 1970-01-01
      • 2019-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多