khalidsheet/oursms

此包已被废弃,不再维护。未建议替换包。

用于发送短信的包装包

1.1.0 2021-06-09 18:36 UTC

This package is auto-updated.

Last update: 2023-02-27 15:23:22 UTC


README

Codacy Badge

https://oursms.app 客户端库,允许您发送短信

安装

使用composer安装oursms客户端

  composer require khalidsheet/oursms

如果您正在运行5.5或更高版本的laravel,请跳过此步骤 包将被自动发现

否则,请运行以下命令

步骤1 - 在 config/oursms.php 下发布包配置文件

  php artisan vendor:publish --provider="Khalidsheet\Oursms\OursmsServiceProvider" --tag="config"

步骤2 - 前往应用程序的 .env 文件,并将这些变量粘贴到文件末尾。

OURSMS_USER_ID=""
OURSMS_KEY=""

使用/示例

导入包

use Khalidsheet\Oursms\Oursms

在您的控制器中,从 Oursms Client 实例化一个新的实例

$oursmsClient = new Oursms();

如果您想发送单条消息

$oursmsClient->sendMessage(string $to, string $message);

如果您想发送Otp消息

$oursmsClient->sendOtp(string $to, string $otp);

如果您想检查消息的状态

$oursmsClient->getSmsStatus(string $messageId);

注意: to 是电话号码,message 是将发送给用户的实际消息。

特性使用/示例

您还可以使用特性向用户发送短信或OTP消息

Messageable 特性添加到您的模型中。

use Khalidsheet\Oursms\Traits\Messageable;

class User extends Model {
     use Messageable;

     ...
}

现在您可以这样使用它

$user = User::find(1);

// Sending OSM 
$user->sendMessage(string $message);

// Sending OTP
$user->sendOtp(string $otp);

注意: 特性功能仅从版本 1.1.0 或更高版本开始提供

作者

许可

MIT