itsmurumba / laravel-hostpinnacle

Laravel Hostpinnacle SMS API 的 Laravel 包

v0.0.3 2024-03-17 13:24 UTC

This package is auto-updated.

Last update: 2024-09-17 15:31:20 UTC


README

官方 Hostpinnacle SMS 服务(API)的 Laravel 包。它包含所有公开可用的端点

  • 快速短信
  • 群组短信
  • 文件上传

安装

运行以下命令以在您的项目中安装 Laravel Hostpinnacle 包

composer require itsmurumba/laravel-hostpinnacle

如果您使用的是 Laravel 5.5 及以上版本,请跳转到 配置 步骤。

运行 composer require 命令后,您应该在 config/app.php 文件中添加一个服务提供者和包别名。(对于 Laravel 5.4 及以下版本)

Itsmurumba\Hostpinnacle\HostpinnacleServiceProvider::class

配置

安装包后,运行以下命令将 hostpinnacle.php 配置文件安装到 config 文件夹中

php artisan hostpinnacle:install

或者

php artisan vendor:publish

在您的 .env 文件中添加并定义以下变量

HOSTPINNACLE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxx
HOSTPINNACLE_SENDER_ID=xxxxxxxxxx
HOSTPINNACLE_LOGIN_USERNAME=xxxxxxxxxxxxxxx
HOSTPINNACLE_LOGIN_PASSWORD=xxxxxx
HOSTPINNACLE_BASE_URL=https://smsportal.hostpinnacle.co.ke/SMSApi

用法

在您的控制器中添加以下构造函数

protected $hostpinnacle;

public function __construct(){
    $this->hostpinnacle = new Hostpinnacle();
}

1. 快速短信

a. 发送快速短信(批量)

$data['mobile'] = '254720xxxxxx';
$data['msg'] = 'Hello World!';

$response = $this->hostpinnacle->sendQuickSMS($data);

b. 发送快速计划短信(批量)

$data['scheduledTime'] = '2023-02-28 17:32:03';
$data['mobile'] = '254720xxxxxx';
$data['msg'] = 'Hello World!';

$response = $this->hostpinnacle->sendQuickScheduledSMS($data);

2. 群组短信

a. 发送群组短信

$data['groupIds'] = '1056';
$data['msg'] = 'Hello World!';

$response = $this->hostpinnacle->sendGroupSMS($data);

b. 发送群组计划短信

$data['scheduledTime'] = '2023-02-28 17:32:03';
$data['groupIds'] = '1056';
$data['msg'] = 'Hello World!';

$response = $this->hostpinnacle->sendGroupScheduledSMS($data);

3. 文件上传短信

a. 仅使用手机号码从文件发送短信

$data['file'] = $request->file('file');
$data['msg'] = 'Hello World!';

$response = $this->hostpinnacle->sendMobileOnlyFileSMS($data);

b. 仅使用手机号码从文件发送计划短信

$data['scheduledTime'] = '2023-02-28 17:32:03';
$data['file'] = $request->file('file');
$data['msg'] = 'Hello World !';

$response = $this->hostpinnacle->sendMobileOnlyFileScheduledSMS($data);

c. 使用手机号码和消息从文件发送短信

$data['file'] = $request->file('file');

$response = $this->hostpinnacle->sendMobileAndMessageFileSMS($data);

d. 使用手机号码和消息从文件发送计划短信

$data['scheduledTime'] = '2023-02-28 17:32:03';
$data['file'] = $request->file('file');

$response = $this->hostpinnacle->sendMobileAndMessageFileScheduledSMS($data);

贡献

这是一个社区包,因此欢迎任何感兴趣的人为改进此包做出贡献。在开始贡献之前,请查阅 Contribution.md。请继续提交 PR 和问题。

买我一杯咖啡

给这个仓库加个星标,我将获得超级力量。您也可以在推特上关注我 @ItsMurumba

许可证

此包采用 MIT 许可证授权。请查阅 许可证 文件以获取详细信息