修正bug
This commit is contained in:
parent
32ad81fc7b
commit
8546ffe85e
@ -19,12 +19,12 @@ class Oauth2Controller extends ControllerBase{
|
|||||||
function testAction(){
|
function testAction(){
|
||||||
//$url = "http://wxapp.wemediacn.com/smsoauth2_qa/api/oauth2/code";
|
//$url = "http://wxapp.wemediacn.com/smsoauth2_qa/api/oauth2/code";
|
||||||
//$url = "http://127.0.0.1/tiffany/api/oauth2/code?qaz=wsx";
|
//$url = "http://127.0.0.1/tiffany/api/oauth2/code?qaz=wsx";
|
||||||
$url = "http://wxapp.wemediacn.com/smsoauth2_qa/api/oauth2/accesstoken";
|
//$url = "http://wxapp.wemediacn.com/smsoauth2_qa/api/oauth2/accesstoken";
|
||||||
//$url = "http://127.0.0.1/tiffany/api/oauth2/accesstoken?qaz=wsx";
|
$url = "http://127.0.0.1/tiffany/api/oauth2/accesstoken?qaz=wsx";
|
||||||
$post_arr = array();
|
$post_arr = array();
|
||||||
$post_arr['appid'] = "0e355010-67b9-4aa6-a53f-c92c972094a7";
|
$post_arr['appid'] = "0e355010-67b9-4aa6-a53f-c92c972094a7";
|
||||||
$post_arr['appsecrect'] = "b82015bd-8d4c-4df8-87a8-c25477a8976f";
|
$post_arr['appsecrect'] = "b82015bd-8d4c-4df8-87a8-c25477a8976f";
|
||||||
$post_arr['code'] = "0807571e456241fcac19c836ed4fd9f7";
|
$post_arr['code'] = "4w6cuxof5gvhi9szpeabj32l71mqrtd8";
|
||||||
$post_json = json_encode($post_arr);
|
$post_json = json_encode($post_arr);
|
||||||
$result = $this->__http_post_request($url, $post_json, true);
|
$result = $this->__http_post_request($url, $post_json, true);
|
||||||
print_r($result); die;
|
print_r($result); die;
|
||||||
|
|||||||
@ -13,14 +13,16 @@ class SmsController extends ControllerBase{
|
|||||||
//特定验证码短信模板
|
//特定验证码短信模板
|
||||||
public $special_authcode_templates = array(
|
public $special_authcode_templates = array(
|
||||||
"7e52ef78-89f1-4f54-ae9b-560e2eca4d79"=>"您的验证码是 [$=yzm=$],60秒内有效。如需协助,欢迎致电:4009213299。如非本人操作请忽略本短信。",
|
"7e52ef78-89f1-4f54-ae9b-560e2eca4d79"=>"您的验证码是 [$=yzm=$],60秒内有效。如需协助,欢迎致电:4009213299。如非本人操作请忽略本短信。",
|
||||||
"3bea8a13-0db4-44cf-ad5b-d585fe5cfc09"=>"您的验证码是 [$=yzm=$],60秒内有效。如需协助,欢迎致电:4009213299。如非本人操作请忽略本短信。"
|
"3bea8a13-0db4-44cf-ad5b-d585fe5cfc09"=>"您的验证码是 [$=yzm=$],60秒内有效。如需协助,欢迎致电:4009213299。如非本人操作请忽略本短信。",
|
||||||
|
"0e355010-67b9-4aa6-a53f-c92c972094a7"=>"你的验证码是[$=yzm=$]"
|
||||||
);
|
);
|
||||||
|
|
||||||
//特定验证码短信参数
|
//特定验证码短信参数
|
||||||
public $special_authcode_params = array(
|
public $special_authcode_params = array(
|
||||||
"1e3ff92c-db9c-4ccf-9903-3be52ac5c25d"=>array("[$=yzm=$]", "[$=params1=$]", "[$=params2=$]", "[$=params3=$]", "[$=params4=$]", "[$=params5=$]"),
|
"1e3ff92c-db9c-4ccf-9903-3be52ac5c25d"=>array("yzm", "params1", "params2", "params3", "params4", "params5"),
|
||||||
"7e52ef78-89f1-4f54-ae9b-560e2eca4d79"=>array("[$=yzm=$]", "[$=params1=$]", "[$=params2=$]", "[$=params3=$]", "[$=params4=$]", "[$=params5=$]"),
|
"7e52ef78-89f1-4f54-ae9b-560e2eca4d79"=>array("yzm", "params1", "params2", "params3", "params4", "params5"),
|
||||||
"3bea8a13-0db4-44cf-ad5b-d585fe5cfc09"=>array("[$=yzm=$]", "[$=params1=$]", "[$=params2=$]", "[$=params3=$]", "[$=params4=$]", "[$=params5=$]"),
|
"3bea8a13-0db4-44cf-ad5b-d585fe5cfc09"=>array("yzm", "params1", "params2", "params3", "params4", "params5"),
|
||||||
|
"0e355010-67b9-4aa6-a53f-c92c972094a7"=>array("yzm", "params1", "params2", "params3", "params4", "params5")
|
||||||
);
|
);
|
||||||
|
|
||||||
function initialize(){
|
function initialize(){
|
||||||
@ -35,18 +37,24 @@ class SmsController extends ControllerBase{
|
|||||||
function testAction(){
|
function testAction(){
|
||||||
//$url = "http://wxapp.wemediacn.com/smsoauth2_qa/api/sms/send";
|
//$url = "http://wxapp.wemediacn.com/smsoauth2_qa/api/sms/send";
|
||||||
//$url = "http://127.0.0.1/tiffany/api/sms/send?qaz=wsx";
|
//$url = "http://127.0.0.1/tiffany/api/sms/send?qaz=wsx";
|
||||||
$url = "http://wxapp.wemediacn.com/smsoauth2_qa/api/sms/authcode";
|
//$url = "http://wxapp.wemediacn.com/smsoauth2_qa/api/sms/authcode";
|
||||||
//$url = "http://127.0.0.1/tiffany/api/sms/authcode?qaz=wsx";
|
$url = "http://127.0.0.1/tiffany/api/sms/authcode?qaz=wsx";
|
||||||
//$url = "http://wxapp.wemediacn.com/smsoauth2_qa/api/sms/query_reports";
|
//$url = "http://wxapp.wemediacn.com/smsoauth2_qa/api/sms/query_reports";
|
||||||
//$url = "http://127.0.0.1/tiffany/api/sms/query_reports?qaz=wsx";
|
//$url = "http://127.0.0.1/tiffany/api/sms/query_reports?qaz=wsx";
|
||||||
$post_arr = array();
|
$post_arr = array();
|
||||||
$post_arr['appid'] = "0e355010-67b9-4aa6-a53f-c92c972094a7";
|
$post_arr['appid'] = "0e355010-67b9-4aa6-a53f-c92c972094a7";
|
||||||
$post_arr['mobile'] = "13501882318";
|
$post_arr['mobile'] = "13501882318";
|
||||||
$post_arr['access_token'] = "71ebca94ab954d67a57af759424a94e1";
|
$post_arr['access_token'] = "ycq9t62einm7usfah1vk4z38djxp5gwl";
|
||||||
$post_arr['content'] = "";
|
$post_arr['content'] = "[$=yzm=$]、[$=params1=$]、[$=params2=$]、[$=params3=$]、[$=params4=$]、[$=params5=$]";
|
||||||
$post_arr['format'] = "";
|
$post_arr['format'] = "";
|
||||||
$post_arr['len'] = -1;
|
$post_arr['len'] = -1;
|
||||||
$post_arr['type'] = -1;
|
$post_arr['type'] = -1;
|
||||||
|
$post_arr['params1'] = 1;
|
||||||
|
$post_arr['params2'] = 2;
|
||||||
|
$post_arr['params3'] = 3;
|
||||||
|
$post_arr['params4'] = 4;
|
||||||
|
$post_arr['params5'] = 5;
|
||||||
|
$post_arr['params6'] = 6;
|
||||||
$post_arr['is_resend'] = true;
|
$post_arr['is_resend'] = true;
|
||||||
$post_arr['min_id'] = "";
|
$post_arr['min_id'] = "";
|
||||||
$post_json = json_encode($post_arr);
|
$post_json = json_encode($post_arr);
|
||||||
@ -490,7 +498,8 @@ class SmsController extends ControllerBase{
|
|||||||
//准备设置验证码
|
//准备设置验证码
|
||||||
$authcode = "";
|
$authcode = "";
|
||||||
//获取是否重发上一个验证码
|
//获取是否重发上一个验证码
|
||||||
$is_resend = !empty($request_arr['is_resend'])?true:false;
|
$is_resend = isset($request_arr['is_resend'])?$request_arr['is_resend']:false;
|
||||||
|
$is_resend = $is_resend?true:false;
|
||||||
//如果是重发上一个验证码
|
//如果是重发上一个验证码
|
||||||
if($is_resend){
|
if($is_resend){
|
||||||
//获取缓存中所传手机号对应的验证码
|
//获取缓存中所传手机号对应的验证码
|
||||||
@ -498,6 +507,8 @@ class SmsController extends ControllerBase{
|
|||||||
}
|
}
|
||||||
//如果以上未设置验证码或缓存中所传手机号对应的验证码已失效
|
//如果以上未设置验证码或缓存中所传手机号对应的验证码已失效
|
||||||
if(empty($authcode)){
|
if(empty($authcode)){
|
||||||
|
//重置是否重发标识
|
||||||
|
$is_resend = false;
|
||||||
//按所传验证码长度及验证码类型生成并设置验证码
|
//按所传验证码长度及验证码类型生成并设置验证码
|
||||||
$authcode = $this->_get_auth_code($len, $type);
|
$authcode = $this->_get_auth_code($len, $type);
|
||||||
}
|
}
|
||||||
@ -537,8 +548,8 @@ class SmsController extends ControllerBase{
|
|||||||
$Content = $request_arr['content'];
|
$Content = $request_arr['content'];
|
||||||
//循环所传appid对应的特定验证码短信参数
|
//循环所传appid对应的特定验证码短信参数
|
||||||
foreach($special_authcode_params[$appid] as $special_authcode_param){
|
foreach($special_authcode_params[$appid] as $special_authcode_param){
|
||||||
//如果当前循环特定验证码短信参数是[$=yzm=$]
|
//如果当前循环特定验证码短信参数是yzm
|
||||||
if($special_authcode_param=="[$=yzm=$]"){
|
if($special_authcode_param=="yzm"){
|
||||||
//将发送短信内容中的[$=yzm=$]参数替换为验证码
|
//将发送短信内容中的[$=yzm=$]参数替换为验证码
|
||||||
$Content = str_replace("[$=yzm=$]", $authcode, $Content);
|
$Content = str_replace("[$=yzm=$]", $authcode, $Content);
|
||||||
}
|
}
|
||||||
@ -547,7 +558,7 @@ class SmsController extends ControllerBase{
|
|||||||
//如果有传具体参数内容
|
//如果有传具体参数内容
|
||||||
if(isset($request_arr[$special_authcode_param])){
|
if(isset($request_arr[$special_authcode_param])){
|
||||||
//将发送短信内容中的当前循环特定验证码短信参数替换为具体参数内容
|
//将发送短信内容中的当前循环特定验证码短信参数替换为具体参数内容
|
||||||
$Content = str_replace($special_authcode_param, $request_arr[$special_authcode_param], $Content);
|
$Content = str_replace("[$=".$special_authcode_param."=$]", $request_arr[$special_authcode_param], $Content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user