lifetimesms/gateway

Lifetimesms 短信发送模块,用于发送业务短信

1.0.0 2019-11-28 07:14 UTC

This package is auto-updated.

Last update: 2024-09-22 01:48:39 UTC


README

Lifeitmesms Laravel 扩展包,用于发送单条或批量短信、语音短信以及查询余额

安装

composer require lifetimesms/gateway

Laravel 5 及以上版本

配置

app/config/app.php 文件中添加以下内容

1- 将 ServiceProvider 添加到 providers 数组中

Lifetimesms\Gateway\LifetimesmsServiceProvider::class,

2- 将类别名添加到 aliases 数组中

'Lifetimesms' =>  Lifetimesms\Gateway\Facades\LifetimesmsFacade::class,

3- 发布配置文件

php artisan vendor:publish --tag="lifetimesms"

配置

.env 文件中添加 LIFETIMESMS_API_TOKENLIFETIMESMS_API_SECRET

LIFETIMESMS_API_TOKEN=api-token
LIFETIMESMS_API_SECRET=api-secret

用法

发送单条短信

$params = ['to' => '03348090100', 'from' => 'Lifetimesms', 'message' => 'Lifetimesms Testing Laravel Package', 'unicode' => false, 'date' => null, 'time' => null];
$response = Lifetimesms::singleSMS($params);

发送批量短信

$params = ['to' => ['0334809000', '03008090100', '03448090100'], 'from' => 'Lifetimesms', 'message' => 'Lifetimesms Testing Laravel Package', 'unicode' => false, 'date' => null, 'time' => null];
$response = Lifetimesms::bulkSMS($params);

发送个性化短信

$params = ['data' => [['to' => '03348090100', 'message' => 'Hello david! its from lifetimesms'], ['to' => '03008090100', 'message' => 'Hello peter! its from lifetimesms']], 'from' => 'Lifetimesms', 'date' => null, 'time' => null];
$response = Lifetimesms::personalizedSMS($params);

发送语音短信

$params = ['to' => ['0334809000', '03008090100', '03448090100'], 'from' => 'Lifetimesms', 'voice_id' => '1', 'date' => null, 'time' => null];
$response = Lifetimesms::voiceSMS($params);

检查投递状态

$params = ['message_id' => '44a82f4e3dd9bd7a091c1127'];
$response = Lifetimesms::deliveryStatus($params);

发送语音请求(文件上传)

$params = ['title' => 'Sample File For Voice SMS', 'file_path' => 'sample.wav'];
// 'file_path' must be the complete path of the audio file
// Valid extensions are mp3 and wav only
$response = Lifetimesms::createVoiceFromFile($params);

发送语音请求(文本转语音)

$params = ['title' => 'Sample Text For Voice SMS', 'text' => 'Sample text of voice sms.'];
$response = Lifetimesms::createVoiceFromTextToSpeech($params);

检查语音状态

$params = ['voice_id' => '1472'];
$response = Lifetimesms::voiceStatus($params);

余额查询

$response = Lifetimesms::balanceInquiry();

网络查找

$params = ['phone_number' => '03008090100'];
$response = Lifetimesms::networkLookup($params);