APP Development of Wotoken Wallet System

Keywords: PHP Mobile JQuery less

Since the launch of Alibaba, the Wotoken wallet system APP has developed T:/ I8O-2853-296O differentiable + many short message platforms, which are close to death. Alibaba is a product of Alibaba, a big brand and a low rate, so many individual webmasters have joined it (not advertising....).

A short message is less than 5 cents, so it is suggested to add the function of short message registration to the website to lock users more accurately.

Next, I will share with you an interface that Ali is bigger than SMS.

First create a send model (Send.php):

namespace appindexmodel;
use thinkValidate;
class Send extends thinkModel

public static $sms_config = [
    'appkey'        => '',//Ali is bigger than APPKEY
    'secretKey'     => '',//Ali is bigger than secretKey
    'FreeSignName'     => 'Ander Rabbit',//Short Message Signature
public function sms($data=[])
    $validate = new Validate([
        ['param','require|array','Parameters must be filled in|The parameters must be arrays'],
        ['mobile','require|/1[34578]{1}\d{9}$/','Error in mobile number|Error in mobile number'],
        ['template','require','Template id error'],
    if (!$validate->check($data)) {
        return $validate->getError();
    define('TOP_SDK_WORK_DIR', CACHE_PATH.'sms_tmp/');
    define('TOP_SDK_DEV_MODE', false);
    $config = self::$sms_config;
    $c = new \TopClient;
    $c->appkey = $config['appkey'];
    $c->secretKey = $config['secretKey'];
    $req = new \AlibabaAliqinFcSmsNumSendRequest;
    $result = $c->execute($req);
    $result = $this->_simplexml_to_array($result);
        return $result['sub_code'];
    return true;

private function _simplexml_to_array($obj)
{//This function is used to transform Ali greater than the returned data, simplexml format into arrays, aspect follow-up use
    if(count($obj) >= 1){
        $result = $keys = [];
        foreach($obj as $key=>$value){
            isset($keys[$key]) ? ($keys[$key] += 1) : ($keys[$key] = 1);
            if( $keys[$key] == 1 ){
                $result[$key] = $this->_simplexml_to_array($value);
            }elseif( $keys[$key] == 2 ){
                $result[$key] = [$result[$key], $this->_simplexml_to_array($value)];
            }else if( $keys[$key] > 2 ){
                $result[$key][] = $this->_simplexml_to_array($value);
        return $result;
    }else if(count($obj) == 0){
        return (string)$obj;

Once the model is created, it can be invoked elsewhere. Let's create a simple index controller for testing:

namespace appindexcontroller;
use appindexmodelSend;
class Index extends thinkController

public function sms()
        $Send = new Send;
        $result = $Send->sms([
            'param'  => ['code'=>'123456','product'=>'Ander Rabbit'],
            'mobile'  => input('','','trim,strip_tags'),
            'template'  => 'SMS_12940581',
        if($result !== true){
            return $this->error($result);
        return $this->success('Successful text messaging!');
    return $this->fetch();

Create a simple template file to test:

<!doctype html>
<html lang="zh-CN">

<meta charset="utf-8">
<title>Ali Bigger Text Sending Test</title>
<base href="{:request()->domain()}" />
<link href="static/css/bootstrap.css" rel="stylesheet">
<link href="static/css/common.css" rel="stylesheet">
<link href="static/css/admin.css" rel="stylesheet">
<script src="static/js/jquery-1.12.0.min.js"></script>
<script src="static/js/bootstrap.min.js"></script>
<script src="static/js/jquery.qrcode.min.js"></script>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>

<div class="container">

<div class="panel panel-default">
    <div class="panel-heading">
        <strong>Ali Bigger Text Sending Test</strong>
    <div class="panel-body">
        <form class="form-horizontal sms-form" method="post" action="{:url('index/index/sms')}">
            <div class="form-group">
                <label class="col-sm-2 control-label">Receiving mobile phone number</label>
                <div class="col-sm-10">
                    <input type="text" class="form-control" name="mobile" value="">
                    <p class="help-block">Click Send SMS, you will receive: "[Ander Rabbit] Verification Code 123456, you are registering as Ander Rabbit user, thank you for your support."</p>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="submit" class="btn btn-success">Send short messages</button>
    <div class="panel-footer">&nbsp;</div>


        var $this = $(this);
            $this.addClass('lock-form');//Lock the form
            var formData = new FormData($this[0]);
                cache: false,
                contentType: false,
                processData: false,
                    $this.removeClass('lock-form');//Unlock forms
                    var html = (s.code != 1 ? 'Error code:' : '')+s.msg;
                    return false;
        return false;


Posted by shane18 on Wed, 09 Oct 2019 20:27:14 -0700