zenapply / laravel-sms
此包已被弃用且不再维护。作者建议使用leadthread/laravel-sms包。
3.0.0-beta.14
2017-08-15 21:52 UTC
Requires
- php: ^5.5.9|^7.0
- illuminate/bus: ^5.2
- illuminate/contracts: ^5.2
- illuminate/queue: ^5.2
- illuminate/support: ^5.2
Requires (Dev)
- bandwidth/catapult: ^0.8.2
- orchestra/testbench: ^3.2
- phpunit/phpunit: ^4.8|^5.0
- plivo/plivo-php: ^1.1
- twilio/sdk: ^5.1
Suggests
- bandwidth/catapult: ^0.8.2
- plivo/plivo-php: ^1.1
- twilio/sdk: ^5.1
- dev-master
- 3.0.0-beta.14
- 3.0.0-beta.13
- 3.0.0-beta.12
- 3.0.0-beta.11
- 3.0.0-beta.10
- 3.0.0-beta.9
- 3.0.0-beta.8
- 3.0.0-beta.7
- 3.0.0-beta.6
- 3.0.0-beta.5
- 3.0.0-beta.4
- 3.0.0-beta.3
- 3.0.0-beta.2
- 3.0.0-beta
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.1
- 2.0.0
- 1.3.0
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.0
- dev-laravel-8
- dev-local
- dev-issue/9/fails-to-purchase-next-number
- dev-add-log-driver
- dev-feature/new/driver-bandwidth
- dev-remove-us-only-validation
- dev-feature-sms-response
- dev-dev-purchase-numbers
This package is auto-updated.
Last update: 2022-03-10 06:01:35 UTC
README
Laravel SMS是一个用于向不同短信服务发送消息的简单Laravel 5包。
当前支持
安装
通过composer安装 - 在终端中
composer require leadthread/laravel-sms
安装Plivo或Twilio SDK
composer require plivo/plivo-php:^1.1 # or composer require twilio/sdk:^4.10 # or composer require bandwidth/catapult:^0.8.2
现在将以下内容添加到你的config/app.php
文件中的providers
数组
LeadThread\Sms\Providers\SmsServiceProvider::class
并将以下内容添加到config/app.php
文件中的aliases
数组
"Sms" => "LeadThread\Sms\Facades\Sms",
然后你需要在终端中运行以下命令以复制配置文件
php artisan vendor:publish
用法
首先,你必须更改位于config/sms.php
的配置文件,并使用你的API凭证。
发送消息
你可以这样简单地发送一条消息
# Send one text $message = "Hello Phone!"; $to = "+15556667777"; $from = "+17776665555"; $response = Sms::send($message,$to,$from);
# Send many texts $message = "Hello Phone!"; $to = ["+15556667777","+15556667778","+15556667779"]; $from = "+17776665555"; $response = Sms::sendMany($message,$to,$from);
# Send many texts with different messages $items = [ ["msg"=>"Hello Rick!", "to"=>"+15556667777","from"=>"+17776665555"], ["msg"=>"Hello Tyler!","to"=>"+15556667778","from"=>"+17776665555"], ["msg"=>"Hello Karla!","to"=>"+15556667779","from"=>"+17776665555"], ]; $response = Sms::sendArray($items);
不要忘记将以下内容添加到文件顶部
//If you updated your aliases array in "config/app.php" use Sms; //or if you didnt... use LeadThread\Sms\Facades\Sms;
购买和销售电话号码
$areacode = '435'; //Search for a number to buy //The response is different for each SMS service provider. This example shows Plivo. $response = Sms::searchNumber($areacode); $number = $response['response']['objects'][0]['number']; //Buy the number Sms::buyNumber($number); //Unrent the number Sms::sellNumber($number);
贡献
贡献总是受欢迎的!如果你希望添加其他服务到列表中,请通过打开一个问题或发送一个pull请求来请求。