destoon短信接口修改方法

destoon是很优秀的B2B行业站程序。程序模块化开发契合度很高,二次开发起来也很顺畅。数据缓存,权限分配,SEO功能方面都不错。

但是在使用这套程序的时候,常常要用到发送短信的功能,而destoon本身只接入了自己的短信接口。一些初接触destoon的开发者不知道如何修改。

所以铁牛特此写个文档分享如何修改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,如果短信发送成功,信息是success,这个发送成功的信息需要在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服务即可

posted @ 2014-03-03 10:32  浮云的等待  阅读(2420)  评论(0编辑  收藏  举报