adresser/smsbot-sdk

该软件包已被弃用且不再维护。未建议替代软件包。

适用于smsbot平台的易于使用的SDK

安装: 0

依赖项: 0

建议者: 0

安全: 0

星标: 3

关注者: 2

分支: 0

开放问题: 0

类型:composer-plugin

0.0.1 2020-09-17 12:30 UTC

This package is auto-updated.

Last update: 2021-07-17 14:56:11 UTC


README

Actions Status LICENSE Packagist

🚀由PHP编写的用于与Smsbot API通信的易于使用的软件开发包。

安装

下载仓库或通过Composer获取(推荐)

$ composer require adresser/smsbot-sdk

版本

该软件包使用 semver

支持的PHP版本

此库支持以下PHP实现

  • PHP 7.2
  • PHP 7.3
  • PHP 7.4

快速入门

  • smsbot 平台上注册
  • 获取您的认证密钥(在设置部分查找)
  • 要使用您的设备发送短信,请连接设备并获取 设备IDSIM ID
  • 要使用HTTP网关发送短信,请创建一个 发送者ID(进入发送者ID部分)

包含 vendor/autoload.php 文件以加载所有库类。

Smsbot 门面提供了SDK的入口。然而,您可以根据需要使用内部类。

有效的电话号码模式

电话号码必须遵循此模式

+(prefix)(number) // es: +13334445566

通过HTTP网关发送短信

注意:要发送 群发短信,请使用 pushDestination 方法添加更多目的地。

use Adresser\Smsbot\Sms;
use Adresser\Smsbot\Facade\Smsbot;

Smsbot::setAuthenticationKey('set the authentication key'); 

$clientFactory = Smsbot::getSmsClientFactory(); 

$client = $clientFactory->getClient('http'); 
$client->setSenderId('put the sender id'); 

// in future this will no longer be needed  
$client->setCountryId('put the country code'); 

$sms = new Sms('test message!'); 
$sms->pushDestination('+39xxxxxxxxxx'); 

$client->send($sms); 

通过注册设备发送短信

注意:要发送 群发短信,请使用 pushDestination 方法添加更多目的地。

use Adresser\Smsbot\Sms;
use Adresser\Smsbot\Facade\Smsbot;

Smsbot::setAuthenticationKey('set the authentication key'); 

$clientFactory = Smsbot::getSmsClientFactory(); 
$client = $clientFactory->getClient('device');

$client->setDeviceId('put the device id here');
$client->setSimId('put the sim id here'); 

$sms = new Sms('test message!'); 
$sms->pushDestination('+39xxxxxxxxxx'); 

$client->send($sms); 

生成OTP

use Adresser\Smsbot\Facade\Smsbot;

Smsbot::setAuthenticationKey('set the authentication key'); 
$factory = Smsbot::getOtpFactory(); 

$generator = $factory->getOtpGenerator(); 
$validator = $factory->getOtpValidator();  

// set the One Time Password lifetime in seconds 
$otp = $generator->generate(3600); 

// the otp will be store inside the smsbot system
if ($validator->validate($otp)) {
    echo "The OTP is valid! \n"; 
} 

使用自定义HTTP客户端

自定义HTTP客户端必须实现 Psr\Http\Client\ClientInterface

$customHttpClient = new CustomHttpClient(); 

$requestDispatcher = new Adresser\Smsbot\RequestDispatcher('auth key', $customHttpClient);

// same with other types of sms clients 
$deviceSmsClient = new Adresser\Smsbot\DeviceSmsClient($requestDispatcher); 

获取帮助

对于任何问题或问题,我们建议您打开一个问题!