destoon是很優(yōu)秀的B2B行業(yè)站程序。程序模塊化開發(fā)契合度很高,二次開發(fā)起來也很順暢。數據緩存,權限分配,SEO功能方面都不錯。
但是在使用這套程序的時候,常常要用到發(fā)送短信的功能,而destoon本身只接入了自己的短信接口。一些初接觸destoon的開發(fā)者不知道如何修改。
所以鐵牛特此寫個文檔分享如何修改destoon如何接入外部短信接口。
第一步:找到/include/global.func.php文件,搜索函數send_sms
修改function send_sms為function send_sms_back,新建函數send_sms
1 function send_sms($mobile, $message, $Word = 0, $time = 0){ 2 global $db, $DT, $DT_TIME, $DT_ip, $_username; 3 if(!$DT['sms'] || !$DT['sms_uid'] || !$DT['sms_key']) return false; 4 $sms_url = 'http://app.com/test/sms.php';//你的短信接口地址 5 //例如你的短信接口是http://app.com/test/sms.php?username=athena&pwd=123456&mobile=15889726201&msg=我的測試短信內容 6 7 $word or $word = word_count($message); 8 $sms_message = rawurlencode(convert($message, DT_CHARSET, 'UTF-8')); 9 //data是你的url字符串 例如:username=athena&pwd=123456&mobile=15889726201&msg=我的測試短信內容10 $data = 'username='.$DT['sms_uid']11 . '&pwd='.$DT['sms_key']12 . '&mobile='.$mobile13 . '&msg='.$sms_message;14 15 //采用PHP的cURL庫推送網頁 16 $cur = curl_init($sms_url);17 curl_setopt($cur, CURLOPT_POST, 1);18 curl_setopt($cur, CURLOPT_POSTFIELDS, $data);19 curl_setopt($cur, CURLOPT_FOLLOWLOCATION, 1);20 curl_setopt($cur, CURLOPT_HEADER, 0);21 curl_setopt($cur, CURLOPT_SSL_VERIFYPEER, 0);22 curl_setopt($cur, CURLOPT_RETURNTRANSFER, 1);23 $rec = curl_exec($cur);24 curl_close($cur);25 $code='';26 if(!$rec==$DT['sms_ok']){27 $code = 'Can Not Connect SMS Server';28 }29 else{30 $code =$DT['sms_ok'];31 }32 33 $db->query("INSERT INTO {$db->PRe}sms (mobile,message,word,editor,sendtime,code) VALUES ('$mobile','$message','$word','$_username','$DT_TIME','$code')");34 35 return $code; 36 }
第二步:設置短信返回值
我的短信接口地址是:http://app.com/test/sms.php,如果短信發(fā)送成功,信息是success,這個發(fā)送成功的信息需要在destoon管理后臺去設置
提示:如果你的curl_init()函數不可用
找到找到php.ini,修改extension=php_curl.dll 把前面的分號去掉如果你的php庫沒有php_curl.dll,那么將php_curl.dll php5ts.dlllibeay32.dll ssleay32.dll 復制到 windows/system32下 重啟IIS或Apache服務即可。
destoon開發(fā)交流群號碼:98537090
新聞熱點
疑難解答