請(qǐng)問如何判斷當(dāng)前的驗(yàn)證碼是來自用戶注冊(cè)還是修改手機(jī)還是重置密碼?
官方代碼中的短信發(fā)送方法中傳遞的參數(shù)無法判斷,現(xiàn)在需要根據(jù)不同的操作發(fā)送不同的短信模板,請(qǐng)問有什么辦法,謝謝。
public function sendsms_text($mobile, $content, $type = 'text') {
if (!$mobile || !$content) {
return dr_return_data(0, dr_lang('手機(jī)號(hào)碼或內(nèi)容不能為空'));
}
$file = WRITEPATH.'config/sms.php';
if (!is_file($file)) {
log_message('error', '短信接口配置文件不存在');
return dr_return_data(0, dr_lang('接口配置文件不存在'));
}
$config = require_once $file;
if ($config['third']) {
if (is_file(ROOTPATH.'config/mysms.php')) {
require_once ROOTPATH.'config/mysms.php';
}
$method = 'my_sendsms_'.$type;
if (function_exists($method)) {
return call_user_func_array($method, [
$mobile,
$content,
$config['third'],
]);
} else {
$error = dr_lang('你沒有定義第三方短信接口: '. $method);
@file_put_contents(WRITEPATH.'sms_log.php', date('Y-m-d H:i:s').' ['.$mobile.'] ['.$error.'] ('.str_replace(array(chr(13), chr(10)), '', $content).')'.PHP_EOL, FILE_APPEND);
return dr_return_data(0, $error);
}
} else {
$content = $type == 'code' ? dr_lang('您的本次驗(yàn)證碼是: %s', $content) : $content;
$url = 'http://www.apdwn.com/index.php?s=vip&c=home&uid='.$config['uid'].'&key='.$config['key'].'&mobile='.$mobile.'&content='.$content.'【'.$config['note'].'】&domain='.trim(str_replace('http://', '', SITE_URL), '/').'&sitename='.SITE_NAME;
$result = dr_catcher_data($url);
if (!$result) {
log_message('error', '訪問官方云短信服務(wù)器失敗');
return dr_return_data(0, dr_lang('訪問官方云短信服務(wù)器失敗'));
}
$result = json_decode($result, true);
}
@file_put_contents(WRITEPATH.'sms_log.php', date('Y-m-d H:i:s').' ['.$mobile.'] ['.$result['msg'].'] ('.str_replace(array(chr(13), chr(10)), '', $content).')'.PHP_EOL, FILE_APPEND);
return $result;
}
這個(gè)判斷不了,是公共類
開源是一種精神,但不是義務(wù),幫忙是情分,不幫也不要抱怨,建議大家多研究代碼、多閱讀代碼、多翻閱社區(qū)歷史問題!
回復(fù)迅??蚣軇?chuàng)始人 好的明白了,希望可以在原函數(shù)sendsms_text()中加入一個(gè)自由參數(shù),由開發(fā)者自行傳參,已在后臺(tái)提交建議工單,希望可以采納,謝謝。
一樓說的一定對(duì),除非自己寫接口了