clk528/sms-library

中国短信平台通用发送的扩展包

0.0.5 2018-08-13 09:59 UTC

README

使用方法

composer require clk528/sms-library

复制 src/config.php 到config目录下 取名为 sms.php

使用方法


<?php
use clk528\SmsLibrary\Sms;

class Test
{
    protected $sms;
    
    public function __construct() 
    {
        $this->sms = new Sms(config('sms',[]));    
    }
    
    /**
    * 单发短信
    * @param $mobile
    * @param $msg
    */
    public function send($mobile,$msg)
    {
        echo json_encode($this->sms->send([
            'mobile' => $mobile,
            'msg' => $msg,
        ]));
        //{"code":1,"message":"发送成功"}
        //{"code":0,"message":"密码错误"}
    }
    
    /**
    * 群发短信
    * @param array $mobile
    * @param $msg
    */
    public function batch_send(array $mobile,$msg)
    {
        echo json_encode($this->sms->BatchSend([
            'mobile' => $mobile,
            'msg' => $msg,
        ]));
        //{"code":1,"message":"发送成功"}
        //{"code":0,"message":"密码错误"}
    }
}

$test = new Test();

$test->send('138xxxxxx','你好我是xxxxx');

$test->batch_send([
    '138xxxxx',
    '138xxxxx',
    '138xxxxx',
    '138xxxxx',
    '138xxxxx'
],'你好我是xxxxx');