最土團購簡訊介面錯誤碼和中文亂碼問題

來源:互聯網
上載者:User

最土團購簡訊介面是最土團購程式的一個整合功能可以串連到簡訊服務商提供的api傳送簡訊。但是很多使用者在使用過程中都遇到了問題,最土團購簡訊介面比較常見的有:

    1. 傳送簡訊失敗,錯誤碼:-2
    2. 傳送簡訊失敗,錯誤碼:-10

      之類的,在解決這些問題之前你要知道你使用的是哪個簡訊服務商,因為不同服務商的簡訊服務api介面地址是不一樣的。
      而最土團購程式裡面的api介面預設是官方提供的:

      1 $api = "http://notice.zuitu.com/sms?user={$user}&pass={$pass}&phones={$phone}&content={$content}";> 

      但有的使用者下載的可能不是官方原版的程式api介面可能被修改過過導致串連不上簡訊介面而產生錯誤,修改方法依次進入目錄:include\function\sms.php 第22行就可以修改了,這裡改成你申請的簡訊api就可以了。

      還有一個就是簡訊發送出去後可能會產生中文亂碼問題,這是因為編碼問題,把編碼轉換成utf8就可以解決。

      在第21行替換代碼:

      $content = urlEncode(mb_convert_encoding($content,'GBK','UTF-8'));

      範例程式碼(官方API)

      <?php function sms_send($phone, $content) {     global $INI;     if (mb_strlen($content, 'UTF-8') < 20) {         return '簡訊長度低於20漢字?長點吧~';     }       /* include customsms function */     $smsowner_file = dirname(__FILE__) . '/smsowner.php';     if (file_exists($smsowner_file)) {          require_once( $smsowner_file);         if(function_exists('sms_send_owner')) {             return sms_send_owner($phone, $content);         }     }     /* end include */       $user = strval($INI['sms']['user']);     $pass = strtolower($INI['sms']['pass']);     if(null==$user) return true;     //$content = urlEncode(mb_convert_encoding($content,'GBK','UTF-8'));//如果為gbk去掉注釋     $api = "http://notice.zuitu.com/sms?user={$user}&pass={$pass}&phones={$phone}&content={$content}";     $res = Utility::HttpRequest($api);     return trim(strval($res))=='0' ? true : strval($res); }   function sms_secret($mobile, $secret, $enable=true) {     global $INI;     $funccode = $enable ? '訂閱' : '退訂';     $content = "{$INI['system']['sitename']},您的手機號:{$mobile} 簡訊{$funccode}功能認證碼:{$secret}。";     sms_send($mobile, $content); }   function sms_bind($mobile, $secret) {     global $INI;     $content = "{$INI['system']['sitename']},您的手機號:{$mobile} 綁定碼:{$secret}。";     sms_send($mobile, $content); }   function sms_coupon($coupon, $mobile=null) {     global $INI;     if ( $coupon['consume'] == 'Y'              || $coupon['expire_time'] < strtotime(date('Y-m-d'))) {         return $INI['system']['couponname'] . '已失效';     }       $user = Table::Fetch('user', $coupon['user_id']);     $order = Table::Fetch('order', $coupon['order_id']);       if (!Utility::IsMobile($mobile)) {         $mobile = $order['mobile'];         if (!Utility::IsMobile($mobile)) {             $mobile= $user['mobile'];         }     }     if (!Utility::IsMobile($mobile)) {         return '請設定合法的手機號碼,以便接受簡訊';     }     $team = Table::Fetch('team', $coupon['team_id']);     $partner = Table::Fetch('partner', $coupon['partner_id']);       $coupon['end'] = date('Y-n-j', $coupon['expire_time']);     $coupon['name'] = $team['product'];     $content = render('manage_tpl_smscoupon', array(                 'partner' => $partner,                 'coupon' => $coupon,                 'user' => $user,                 ));       if (true===($code=sms_send($mobile, $content))) {         Table::UpdateCache('coupon', $coupon['id'], array(                     'sms' => array('`sms` + 1'),                     'sms_time' => time(),                     ));         return true;     }     return $code; }   function sms_voucher($voucher, $mobile=null) {     global $INI;     $user = Table::Fetch('user', $voucher['user_id']);     $order = Table::Fetch('order', $voucher['order_id']);       if (!Utility::IsMobile($mobile)) {         $mobile = $order['mobile'];         if (!Utility::IsMobile($mobile)) {             $mobile= $user['mobile'];         }     }     if (!Utility::IsMobile($mobile)) {         return '請設定合法的手機號碼,以便接受簡訊';     }       $team = Table::Fetch('team', $voucher['team_id']);     $partner = Table::Fetch('partner', $team['partner_id']);       $voucher['end'] = date('Y-n-j', $team['expire_time']);     $voucher['name'] = $team['product'];     $content = render('manage_tpl_smsvoucher', array(                 'partner' => $partner,                 'voucher' => $voucher,                 'user' => $user,                 ));       if (true===($code=sms_send($mobile, $content))) {         Table::UpdateCache('voucher', $voucher['id'], array(                     'sms' => array('`sms` + 1'),                     'sms_time' => time(),                     ));         return true;     }     return $code; }   function sms_express($id, &$flag=null) {     $order = Table::Fetch('order', $id);     $team = Table::Fetch('team', $order['team_id']);     if (!$order['express_id']) {         $flag = 'No express';         return false;     }     $express = Table::Fetch('category', $order['express_id']);     $html = render('manage_tpl_smsexpress', array(                 'team' => $team,                 'express_name' => $express['name'],                 'express_no' => $order['express_no'],                 ));     $phone = $order['mobile'];     if ( true === ($flag = sms_send($phone, $html)) ) {         Table::UpdateCache('order', $id, array(             'sms_express' => 'Y',         ));         return true;     }     return false; }

       

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.