function sms_send_randcode_nocompany($code, $mobile, $tpl_id) { $CI =& get_instance(); $CI->config->load('oauth2'); $sms_info = $CI->config->item('sms_info'); $api_key = $sms_info['apikey']; $tpl_value = "#code#={$code}"; return tpl_send_sms($api_key, $tpl_id, $tpl_value, $mobile); }
function pinet_send_randcode_nocompany($code, $mobile, $tpl_id = 550169) { $default_agent_cfg = C('default_agent_info'); $apikey = $default_agent_cfg['sms_apikey']; $tpl_value = "#code#={$code}"; return tpl_send_sms($apikey, $tpl_id, $tpl_value, $mobile); }
// $mobile = guolv($_GET['phone']); //请用自己的手机号代替 // $yzm1 = substr($mobile,3,4); // $text="您的验证码是{$yzm1}"; // echo send_sms($apikey,$text,$mobile); //模板接口样例(不推荐。需要测试请将注释去掉。) //以下代码块已被注释 //5b4aa85957d6b5ce942ac4c9e8e343fe $apikey = $config['yunpian']; //请用自己的apikey代替 $mobile = guolv($_GET['phone']); //请用自己的手机号代替 $yzm1 = substr($mobile, 3, 4); $tpl_id = 1; //对应默认模板 【#company#】您的验证码是#code# $tpl_value = "#company#={$config['sitename']}&#code#={$yzm1}"; echo tpl_send_sms($apikey, $tpl_id, $tpl_value, $mobile); /** * 通用接口发短信 * apikey 为云片分配的apikey * text 为短信内容 * mobile 为接受短信的手机号 */ function send_sms($apikey, $text, $mobile) { $url = "http://yunpian.com/v1/sms/send.json"; $encoded_text = urlencode("{$text}"); $post_string = "apikey={$apikey}&text={$encoded_text}&mobile={$mobile}"; return sock_post($url, $post_string); } /** * 模板接口发短信