织梦(DEDECMS)增加发送短信功能
打开common.func.php,添加如下自定义函数sendsms
/** * 发送短信 (同创凌凯接口) * @param $content 短信内容 * @param $telphone 手机号码,多个号码中间用英文,隔开 * @return int 大于等于0正常,否则错误 */ function sendsms($content='',$telphone='') { //短信接口用户名 通信商提供 $userid = 'TCLKJ01000'; //短信接口密码 通信商提供 $passwd = '********'; $content = urlencode($content.'咨询电话010-60213422【惠臣】'); //如果网站编码是utf-8,请用下面这句。 //$content = urlencode(mb_convert_encoding($content.'【惠臣】',"gbk","utf-8")); $gateway = "http://inolink.com/ws/BatchSend.aspx?CorpID={$userid}&Pwd={$passwd}&Mobile={$telphone}&Content={$content}&Cell=&SendTime="; $result = file_get_contents($gateway); if($result<0){//错误记录 $fp = fopen(dirname(__FILE__)."/../data/sms.txt","a"); flock($fp, LOCK_EX) ; fwrite($fp,$result.",执行日期:".strftime("%Y-%m-%d %H:%I:%S",time())."\r\n"); flock($fp, LOCK_UN); fclose($fp); } return $result; }