【短信防火墙】后端接入---PHP接入指引
发布时间:2021-01-27 点击数:7587
              
       
后端接入---PHP接入指引
本篇教程介绍如何在PHP后端接入防火墙。
快速接入步骤
1、添加必要的php、js文件
fp.js
nxt_client.php
nxt_front.php
nxt_ini.php
tripledes.js (存放位置:"\nxt_inc)
(在本地服务页面下载:http://localhost:7502)
2、 修改相关配置
nxt_ini.php (存放位置:"\nxt_inc")
修改参数($GLOBALS ["fireWareUrl"])-->$GLOBALS ["fireWareUrl"]="http://localhost:7502"
3、 各场景示例代码(注:短信下发和短信验证须成对出现)
1. 短信下发
require_once $_SERVER['DOCUMENT_ROOT'].
"/nxt_inc/nxt_client.php";
/**
 * 发送短信
 * @param $mobile
 */
public
function send(string $mobile) {
    $fwClient = new ClientApi();
    // 获取下发短信报文
    $paramMap = $fwClient - > getSendReq($phone);
    // 执行下发短信请求 
    $jsonReq = $fwClient - > execReq($paramMap);
    $fwRet = $fwClient - > getRetVaule($jsonReq, "riskResult");
    if("REJECT" != $fwRet) {
        // 发送短信业务 TODO
        if(发送成功标记) {
            //  下发短信成功
            $fwClient - > execSucc($paramMap);
        }
        else {
            //  下发短信失败
            $fwClient - > execFail($paramMap);
        }
    }
}
2. 短信验证
/** * 短信验证 * @param $mobile */ public function smsVerify(string $mobile) { $fwClient = new ClientApi(); // 获取短信验证报文 $paramMap = $fwClient - > getVerifyReq($phone); // 执行短信验证请求 $jsonReq = $fwClient - > execReq($paramMap); $fwRet = $fwClient - > getRetVaule($jsonReq, "riskResult"); if("REJECT" != $fwRet) { // 验证短信业务 TODO if(验证成功标记) { // 验证短信成功 $fwClient - > execSucc($paramMap); } else { // 验证短信失败 $fwClient - > execFail($paramMap); } } }
3. 用户登录
/** * 用户登录 * @param $mobile */ public function loginByPwd(string $mobile) { $fwClient = new ClientApi(); // 获取登录报文 $paramMap = $fwClient - > getLoginByMobile($phone); // 执行登录请求 $jsonReq = $fwClient - > execReq($paramMap); $fwRet = $fwClient - > getRetVaule($jsonReq, "riskResult"); if("REJECT" != $fwRet) { // 登录业务 TODO if(登录成功标记) { // 登录成功 $fwClient - > execSucc($paramMap); } else { // 登录失败 $fwClient - > execFail($paramMap); } } }

