财务系统开发文档>短信接口
c/plugins/sms目录下1、文件命名1)、新建目录,在“public/plugins/sms/”下新建你要开发的短信插件目录名。2)、新建文件,在新建的目录下,创建文件,文件的名称和新建目录要一致。例如要开发idcsmart短信插件就在sms目录下创建idcsmart文件夹,在idcsmart文件夹下创建IdcsmartPlugin.php。配置项文件固定名称config.php。2、文件中规范(以idcsmart短信插件开发为例)1)、创建命名空间 namespace sms\idcsmart;2)、使用插件 use app\admin\lib\Plugin;2)、创建类名 IdcsmartPlugin (类名和文件名一致,继承Plugin类)3)、类中配置函数 (下面四个函数名是固定,不能改也不能缺失,其它需要的功能自己写函数) 3、类中参数、基本函数1)、 基础信息(不能为空)public $info = array( 'name' => 'Idcsmart',//插件类名不带Plugin 'title' => '智简魔方', 'description' => '智简魔方官方短信平台接口', 'status' => 1, 'author' => '魔方财务', 'version' => '1.0', 'help_url' => 'https://www.idcsmat.com/',//申请接口地址);2)、install (安装插件函数) 安装插件,这里如果写了返回导入的模板信息,在安装时就会创建模板。导入模板的数据格式看idcsmart目录下的config/smsTemplate.php 不需要导入模板,返回true。3)、uninstall (卸载插件函数,没有操作返回true)4)、description(财务系统后台页面创建模板页面时可用参数,不能为空) 返回html内容,数据格式看idcsmart目录下的config/description.html4、类中短信接口操作函数系统返回给以下函数的公共参数$params['config'] //config.php中的配置项在安装插件后,设置后的数组1)、getCnTemplate($params) //获取国内模板 函数接收参数: $params['template_id'] //模板ID 返回数据格式: status//状态只有两种(成功success,失败error) template_id//模板的ID(获取的模板ID) template_status//只能是1,2,3(1正在审核,2审核通过,3未通过审核) msg//接口返回的错误消息传给msg参数 [ 'status'=>'success', 'template'=>[ 'template_id'=>'w34da', 'template_status'=>2, 'msg'=>"模板审核失败", ] ] 获取失败 [ 'status'=>'error', 'msg'=>'模板ID错误', ]2)、createCnTemplate($params) //创建国内模板 函数接收参数: $params['title'] //模板标题 $params['content'] //模板内容 $params['remark'] //模板备注 返回数据格式: status//状态只有两种(成功success,失败error) template_id//模板的ID, template_status//只能是1,2,3(1正在审核,2审核通过,3未通过审核) msg//接口返回的错误消息传给msg参数 成功 [ 'status'=>'success', 'template'=>[ 'template_id'=>'w34da', 'template_status'=>1, ] ] 失败 [ 'status'=>'error', 'msg'=>'模板ID错误', ]3)、putCnTemplate($params) //修改国内模板 函数接收参数: $params['template_id'] //模板ID $params['title'] //模板标题 $params['content'] //模板内容 $params['remark'] //模板备注 返回数据格式: status//状态只有两种(成功success,失败error) template_status//只能是1,2,3(1正在审核,2审核通过,3未通过审核) msg//接口返回的错误消息传给msg参数 成功 [ 'status'=>'success', 'template'=>[ 'template_status'=>2, ] ] 失败 [ 'status'=>'error', 'msg'=>'模板ID错误', ]4)、deleteCnTemplate($params) //删除国内模板 函数接收参数: $params['template_id'] //模板ID 返回数据格式: status//状态只有两种(成功success,失败error) template_status//只能是1,2,3(1正在审核,2审核通过,3未通过审核) msg//接口返回的错误消息传给msg参数 成功 [ 'status'=>'success', ] 失败 [ 'status'=>'error', 'msg'=>'模板ID错误', ]5)、sendCnSms($params) //发送国内短信 函数接收参数: $params['template_id'] //模板ID $params['templateParam'] //替换模板内容的参数 $params['content'] //模板内容 $params['mobile'] //模板手机号 返回数据格式: status//状态只有两种(成功success,失败error) content//替换参数过后的模板内容 msg//接口返回的错误消息传给msg参数 成功 [ 'status'=>'success', 'content'=>'验证码43543发送成功', ] 失败 [ 'status'=>'error', 'content'=>'error', 'msg'=>'手机号错误', ]6)、国际接口函数(如果该接口支持国际接口就写,没有则不写) 国际接口函数有 getGlobalTemplate//获取国际模板 createGlobalTemplate//创建国际模板 putGlobalTemplate//修改国际模板 deleteGlobalTemplate//删除国际模板 sendGlobalTemplate//发送国际短信 函数接收参数: 同国内函数对应 返回数据格式: 同国内函数对应