PHP code example of starrysea / gosstone

1. Go to this page and download the library: Download starrysea/gosstone library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

starrysea / gosstone example snippets


'providers' => [
    // ...
    Starrysea\Gosstone\SmsServiceProvider::class,
];

'aliases' => [
    // ...
    'GosstoneSms' => Starrysea\Gosstone\Sms::class,
];

return [
    // 缓存时间(单位:秒)
    'cachetime' => 600,

    // 机构ID:用户名
    'username' => '',

    // 账户密码
    'password' => '',
];

$app->register(Starrysea\Gosstone\SmsServiceProvider::class); // 注册 GosstoneSms 服务提供者

class_alias(Starrysea\Gosstone\Sms::class, 'GosstoneSms'); // 添加 GosstoneSms 门面

use Starrysea\Gosstone\Sms;

class SmsGatherTest
{
    // send sms verify code
    public static function send()
    {
        return Sms::first()
            ->phone('13333339558') // set accept sms of phone code
            ->setMessage('你的登录验证码为:') // set sms content
            ->setVerifycode('login') // set verify code and in redis cache, cache name: login
            ->setMessage(',') // append sms content
            ->tail('千万千万不要告诉别人哦!') // set sms tail
            ->execute(); // send sms
    }

    // verify sms verify code
    public static function verifycode()
    {
        return Sms::proveVerifycode('login','13333339558','$code');
    }

    // del redis verify code
    public static function delverifycode()
    {
        return Sms::delVerifycode('login','13333339558','$code');
    }

    // get sms user info
    public static function getuser()
    {
        return Sms::first()->GetUser();
    }

    // update database sms status
    public static function upsmsstatus()
    {
        return Sms::first()->MatchStatus();
    }

    // get database sms status
    public static function gettype()
    {
        return Sms::GetType(0); // 未知
//        return GosstoneSms::GetType(1); // 成功
//        return GosstoneSms::GetType(2); // 失败
    }
}
bash
php artisan vendor:publish --provider="Starrysea\Gosstone\SmsServiceProvider" --tag="migrations"
bash
php artisan migrate
bash
php artisan vendor:publish --provider="Starrysea\Gosstone\SmsServiceProvider" --tag="config"
bash
cp vendor/starrysea/gosstone/config/gosstonesms.php config/gosstonesms.php

cp vendor/starrysea/gosstone/database/migrations/create_smsoutbox_table.php.stub database/migrations/2019_01_01_000000_create_smsoutbox_table.php
bash
php artisan migrate