Example #1
0
 /**
  * 亿美短信发送接口
  * @param unknown $mobile 手机号
  * @param unknown $content 短信内容
  */
 private function _sendEmay($mobile, $content)
 {
     set_time_limit(0);
     define('SCRIPT_ROOT', BASE_DATA_PATH . '/api/emay/');
     require_once SCRIPT_ROOT . 'include/Client.php';
     /**
      * 网关地址
      */
     $gwUrl = C('sms.gwUrl');
     /**
      * 序列号,请通过亿美销售人员获取
      */
     $serialNumber = C('sms.serialNumber');
     /**
      * 密码,请通过亿美销售人员获取
      */
     $password = C('sms.password');
     /**
      * 登录后所持有的SESSION KEY,即可通过login方法时创建
      */
     $sessionKey = C('sms.sessionKey');
     /**
      * 连接超时时间,单位为秒
      */
     $connectTimeOut = 2;
     /**
      * 远程信息读取超时时间,单位为秒
      */
     $readTimeOut = 10;
     /**
     $proxyhost		可选,代理服务器地址,默认为 false ,则不使用代理服务器
     $proxyport		可选,代理服务器端口,默认为 false
     $proxyusername	可选,代理服务器用户名,默认为 false
     $proxypassword	可选,代理服务器密码,默认为 false
     */
     $proxyhost = false;
     $proxyport = false;
     $proxyusername = false;
     $proxypassword = false;
     $client = new Client($gwUrl, $serialNumber, $password, $sessionKey, $proxyhost, $proxyport, $proxyusername, $proxypassword, $connectTimeOut, $readTimeOut);
     /**
      * 发送向服务端的编码,如果本页面的编码为GBK,请使用GBK
      */
     $client->setOutgoingEncoding("UTF-8");
     $statusCode = $client->login();
     if ($statusCode != null && $statusCode == "0") {
     } else {
         //登录失败处理
         //    echo "登录失败,返回:".$statusCode;exit;
     }
     $statusCode = $client->sendSMS(array($mobile), $content);
     if ($statusCode != null && $statusCode == "0") {
         return true;
     } else {
         return false;
         print_R($statusCode);
         echo "处理状态码:" . $statusCode;
     }
 }
 private function sendSms($mobile, $content)
 {
     require_once APPPATH . 'libraries/sms/Client.php';
     //$sms_config = $this->tickets->select('configs',array('tc_type'=>'sms_config'));
     $sql = "select * from t_configs where 1=1 and tc_type='sms_config'";
     $sms_config = $this->db->query($sql)->row();
     if (!$sms_config) {
         return false;
     } else {
         $config = $sms_config;
     }
     /**
      * 网关地址
      */
     $gwUrl = 'http://sdk4report.eucp.b2m.cn:8080/sdk/SDKService';
     /**
      * 序列号,请通过亿美销售人员获取
      */
     $serialNumber = $config->tc_title;
     //'6SDK-EMY-6688-KGZSP';
     /**
      * 密码,请通过亿美销售人员获取
      */
     $password = $config->tc_content;
     //'845379';
     /**
      * 登录后所持有的SESSION KEY,即可通过login方法时创建
      */
     $sessionKey = '123456';
     /**
      * 连接超时时间,单位为秒
      */
     $connectTimeOut = 2;
     /**
      * 远程信息读取超时时间,单位为秒
      */
     $readTimeOut = 10;
     $proxyhost = false;
     $proxyport = false;
     $proxyusername = false;
     $proxypassword = false;
     $client = new Client($gwUrl, $serialNumber, $password, $sessionKey, $proxyhost, $proxyport, $proxyusername, $proxypassword, $connectTimeOut, $readTimeOut);
     /**
      * 发送向服务端的编码,如果本页面的编码为GBK,请使用GBK
      */
     $client->setOutgoingEncoding("utf8");
     $statusCode = $client->login();
     $statusCode = $client->sendSMS(array($mobile), $content);
     if ($statusCode == 0) {
         return true;
     } else {
         return false;
     }
 }
/**
 * 短信发送 用例
 * @param array $mobiles
 * @param string $content
 * @return int $errorcode
 */
function mobileSMS($mobiles, $content)
{
    set_time_limit(0);
    header("Content-Type: text/html; charset=UTF-8");
    #定义程序绝对路径
    define('SCRIPT_ROOT', FCPATH . APPPATH . 'libraries/sms/');
    require_once SCRIPT_ROOT . 'include/Client.php';
    #网关地址
    $gwUrl = 'http://sdkhttp.eucp.b2m.cn/sdk/SDKService?wsdl';
    #序列号,请通过亿美销售人员获取
    $serialNumber = '3SDK-EMY-0130-JFTRN';
    #密码,请通过亿美销售人员获取
    $password = '******';
    #登录后所持有的SESSION KEY,即可通过login方法时创建
    $sessionKey = '169304';
    #连接超时时间,单位为秒
    $connectTimeOut = 2;
    #远程信息读取超时时间,单位为秒
    $readTimeOut = 10;
    /**
    $proxyhost		可选,代理服务器地址,默认为 false ,则不使用代理服务器
    $proxyport		可选,代理服务器端口,默认为 false
    $proxyusername	可选,代理服务器用户名,默认为 false
    $proxypassword	可选,代理服务器密码,默认为 false
    */
    $proxyhost = false;
    $proxyport = false;
    $proxyusername = false;
    $proxypassword = false;
    $client = new Client($gwUrl, $serialNumber, $password, $sessionKey, $proxyhost, $proxyport, $proxyusername, $proxypassword, $connectTimeOut, $readTimeOut);
    #发送向服务端的编码,如果本页面的编码为GBK,请使用GBK
    $client->setOutgoingEncoding("UTF8");
    #global $client;
    /*
     * 下面的代码将发送内容为 test 给 159xxxxxxxx 和 159xxxxxxxx
     * $client->sendSMS还有更多可用参数,请参考 Client.php
     */
    #第一次使用需要先执行,以后无需再执行,除非调用logout
    #$statusCode = $client->login($sessionKey);
    $msg = '【赛酷网】' . $content;
    $statusCode = $client->sendSMS($mobiles, $msg);
    if ($statusCode != '' && $statusCode == 0) {
        return true;
    } else {
        return false;
    }
}