当前位置: 首页>>代码示例>>PHP>>正文


PHP Sms::formatCellNumber方法代码示例

本文整理汇总了PHP中Sms::formatCellNumber方法的典型用法代码示例。如果您正苦于以下问题:PHP Sms::formatCellNumber方法的具体用法?PHP Sms::formatCellNumber怎么用?PHP Sms::formatCellNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sms的用法示例。


在下文中一共展示了Sms::formatCellNumber方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: send

 public function send()
 {
     $logTypes = new logTypes();
     $logUrgency = new LogUrgency();
     $err = $logTypes->getRow(array('where' => '`name`="error"'));
     $warn = $logTypes->getRow(array('where' => '`name`="warning"'));
     $med = $logUrgency->getRow(array('where' => '`name`="medium"'));
     $url = (string) 'http://bulksms.2way.co.za/eapi/submission/';
     $url .= strlen($this->_body) > 160 ? 'send_batch/1/1.0' : 'send_sms/2/2.0';
     $port = 80;
     $fields = (string) '';
     $post_fields = (array) array('username' => $this->_user, 'password' => $this->_pass);
     if (strlen($this->_body) > 160) {
         $messagearray = str_split($this->_body, 155);
         $post_fields['batch_data'] = (string) 'msisdn,message' . '~';
         if (is_array($this->_to)) {
             foreach ($this->_to as $value) {
                 foreach ($messagearray as $line) {
                     if (parent::formatCellNumber($value)) {
                         $post_fields['batch_data'] .= '"' . parent::formatCellNumber($value) . '","' . $line . '"~';
                     }
                 }
             }
         } else {
             foreach ($messagearray as $line) {
                 if (parent::formatCellNumber($this->_to)) {
                     $post_fields['batch_data'] .= '"' . parent::formatCellNumber($this->_to) . '","' . $line . '"~';
                 }
             }
         }
         $post_fields['batch_data'] = rtrim($post_fields['batch_data'], '~');
     } else {
         $post_fields['message'] = $this->_body;
         if (is_array($this->_to)) {
             $post_fields['msisdn'] = (string) '';
             foreach ($this->_to as $value) {
                 if (parent::formatCellNumber($value)) {
                     $post_fields['msisdn'] .= parent::formatCellNumber($value) . ',';
                 }
             }
             $post_fields['msisdn'] = rtrim($post_fields['msisdn'], ',');
         } else {
             if (parent::formatCellNumber($this->_to)) {
                 $post_fields['msisdn'] = parent::formatCellNumber($this->_to);
             }
         }
     }
     foreach ($post_fields as $key => $value) {
         if ($key == 'batch_data') {
             $split = preg_split('/~/', $value);
             $fields .= urlencode($key) . '=';
             foreach ($split as $skey => $sval) {
                 $fields .= urlencode($sval) . '%0A';
             }
             $fields = rtrim($fields, '%0A');
         } else {
             $fields .= urlencode($key) . '=' . urlencode($value) . '&';
         }
     }
     $fields = rtrim($fields, '&');
     if ($this->_test) {
         echo '<pre>number:<br />';
         print_r($this->_to);
         echo '<br />message:<br />';
         print_r($this->_body);
         echo '<br />fields:<br />';
         print_r($fields);
         echo '<br />message array:<br />';
         print_r(isset($messagearray) ? $messagearray : '');
         echo '</pre>';
         return false;
     }
     $ch = curl_init();
     //: open the curl connection/
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
     # Added by Feighen 2010-11-03 11h16
     curl_setopt($ch, CURLOPT_PORT, $port);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
     $response_string = curl_exec($ch);
     $curl_info = curl_getinfo($ch);
     if ($response_string === false) {
         // do some logging
         $data = (array) array();
         $data["log_typeid"] = $err['id'];
         $data["log_urgencyid"] = $med['id'];
         $data["title"] = "Could not successfully execute cURL statement";
         $data["userid"] = $_SESSION['userid'];
         $data["message"] = preg_replace("/'/", "\\'", "cURL returned the following error: " . curl_error($ch));
         $data["file"] = __FILE__;
         $data["update_at"] = $_SERVER['REQUEST_TIME'];
         $data["create_at"] = $_SERVER['REQUEST_TIME'];
         $data["url"] = $_SERVER['REQUEST_URI'];
         if ($this->_log->create($data) === false) {
             throw new man_exception("Could not successfully query the database");
         }
         return false;
     } elseif ($curl_info['http_code'] != 200) {
//.........这里部分代码省略.........
开发者ID:RoneilZA,项目名称:dashboards,代码行数:101,代码来源:BulkSms.class.2011.04.20.php


注:本文中的Sms::formatCellNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。