dannyvilla/1s2u-sms

这是一个通过https://www.1s2u.com网关发送短信(SMS)的包。

v1.2.3 2022-06-03 10:12 UTC

This package is auto-updated.

Last update: 2024-09-30 01:43:23 UTC


README

这是一个通过https://www.1s2u.com网关发送短信(SMS)的包。

安装

使用包管理器composer安装1s2u-sms。

composer require dannyvilla/1s2u-sms

OneServiceToYouSMSServiceProdiver默认自动发现并注册,但如果您想自己注册它

在config/app.php中添加ServiceProvider

'providers' => [
    /*
     * Package Service Providers...
     */
    Oxanfoxs\OneServiceToYouSMS\Provider\OneServiceToYouSMSServiceProdiver::class,

]

在config/app.php中添加Facade

'aliases' => [
    ...
    
    'MessageApi' => Oxanfoxs\OneServiceToYouSMS\Facades\MessageApi::class,

]

您应该发布此包以获取对配置文件的访问权限

php artisan vendor:publish --provider="Oxanfoxs\OneServiceToYouSMS\Provider\OneServiceToYouSMSServiceProdiver"

这将创建一个名为config/1s2u.php的新配置文件。然后您可以在1s2u配置文件中更新凭证。

     ...

    'username' => 'your-username-here',

     ....

    'password' => 'your-password-here',

用法

1s2u API允许发送两种类型的消息。

  • 简单文本消息:此类消息只包含GSM 03.38字符
  • Unicode消息:此类消息使用UCS-2字符集。
发送自动检测类型的消息。
$response = MessageApi::setMessage('Hello word')
                      ->setSenderId('SMS')
                      ->setMobileNumbers(['123456789', '234567891'])
                      ->appendNumber('123456678')
                      ->send();
发送简单文本消息。
$response = MessageApi::setMessage('Hello word', MessageApi::SIMPLE_TEXT_MESSAGE)
                      ->setSenderId('FROM')
                      ->setMobileNumbers(['1234567890'])
                      ->send();
发送Unicode消息。
$response = MessageApi::setMessage('Hello word', MessageApi::UNICODE_MESSAGE)
                      ->setSenderId('FROM')
                      ->setMobileNumbers(['1234567890'])
                      ->send();
发送闪存消息。
$response = MessageApi::setMessage('Hello word')
                      ->setSenderId('FROM')
                      ->setMobileNumbers(['1234567890'])
                      ->shouldFlash(true)
                      ->send();
检查余额。

\Oxanfoxs\OneServiceToYouSMS\MessageApi::checkCredit()方法允许检查余额。

$response = MessageApi::checkCredit()

有关响应的更多信息,请查看官方文档此处

贡献

欢迎提交拉取请求。对于主要更改,请先打开一个问题来讨论您想更改的内容。

许可证

MIT