softsmart / smsportal-laravel
SMSPortal集成包,用于Laravel框架。
1.1.1
2023-01-10 12:37 UTC
Requires
- php: ^7.3 || ^8.0
- illuminate/support: ^8.0 || ^9.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-09-10 16:32:33 UTC
README
第三方包,用于调用SMSPortal RESTful API向电话号码发送短信。
安装
您可以通过Composer安装此包
composer require softsmart/smsportal-laravel
设置以下.env
变量
SMSPORTAL_BASE_URL=https://rest.smsportal.com/v1 SMSPORTAL_CLIENT_ID= SMSPORTAL_SECRET= SMSPORTAL_TEST_MODE=true/false
您可以在SMSPortal控制面板中找到您的客户端ID和密钥。
使用方法
// To send a message to a single phone number SMSPortal::sendMessage('0112223333', 'Hello world!'); // To send a message to a single phone number later // NOTES: even though replacements is not used for single SMS we still need to // account for its place (this may change with named parameters in PHP8 in later versions) // date time is a string in GMT+2 timezone SMSPortal::sendMessage('0112223333', 'Hello world!', [], "2023-01-12 12:34:33");
// To send a message to a multiple phone numbers (without text replacements) $numbers = [ "0000000000", "00000000001", ]; SMSPortal::sendMessage($numbers, 'Hello world!'); // To send a message to a multiple phone numbers later // NOTES: must account for replacements place (this may change with named parameters in PHP8 in later versions) // date time is a string in GMT+2 timezone SMSPortal::sendMessage($numbers, 'Hello world!', [], "2023-01-12 12:34:33");
// To send a message to a multiple phone numbers (with text replacements) // Replacements must be an array of array arrays with a key attribute and a value attribute // Its up to you to determine the key, in this is its ::first_name:: but it could be {first_name}, etc. $numbers = [ "0000000000", "0000000001", ]; $replacements = [ // first replacement [ [ "key" => "::first_name::", "value" => "John" ], [ "key" => "::weather::", "value" => "hot", ] ], // second replacement [ [ "key" => "::first_name::", "value" => "Alice" ], [ "key" => "::weather::", "value" => "cold", ] ], ] SMSPortal::sendMessage($numbers, 'Hello ::first_name::, today is ::weather::!', $replacements); // To send a message to a multiple phone numbers later // date time is a string in GMT+2 timezone SMSPortal::sendMessage($numbers, 'Hello ::first_name::, today is ::weather::!', $replacements, "2023-01-12 12:34:33");
变更日志
请参阅变更日志以获取最近更改的更多信息。
贡献
请参阅贡献指南以获取详细信息。
安全
如果您发现任何安全相关的问题,请使用问题跟踪器。
致谢
许可
MIT许可(MIT)。请参阅许可文件以获取更多信息。