alexzvn/speedsms-api

v0.0.1 2021-03-05 05:19 UTC

This package is auto-updated.

Last update: 2024-09-17 15:28:52 UTC


README

安装

通过Composer安装

composer require alexzvn/speedsms-api

使用Speedsms API

首先在PHP脚本中引入自动加载。

<?php

use Alexzvn\Speedsms\Speedsms;

require_once 'path-to/vendor/autoload.php';

$sms = new Speedsms('your api key goes here');

查询账户信息

// Fetch information from speedsms.vn
// Because speedsms suck then whenever api key invalid,
//  you will hit 404 error exception
$user = $sms->getUserInfo();

// get email
$user->email();

// get balance (int)
$user->balance();

向电话号码发送短信

$phone = '0355012345';

// maximum is 160 length for ascii and 70 if contains unicode
// other wise you'll hit Alexzvn\Speedsms\MessageLengthException
$message = 'your message'; 

$type = Speedsms::SMS_SUPPORT;

// depend on type you choice
// for sms support no needed
$sender = '';

$response = $sms->sendSms($phone, $message, $type, $sender);

处理传入的回调短信

$sms = Speedsms::incoming()

// get phone
$sms->phone

// get message
$sms->message

// and get type
$sms->type

贡献

请随意为此包创建pull request或issue。

许可证

该包在MIT许可证的条款下作为开源软件提供。MIT License.