diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 75144a7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: php - -php: - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - 7.3 - -dist: trusty -sudo: false - -install: travis_retry composer install --no-interaction --prefer-source - -script: ./vendor/bin/phpunit --verbose --coverage-text diff --git a/README.md b/README.md index 24c86b2..6126c7d 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@

:calling: 一款满足你的多种发送需求的短信发送组件

-Build Status Latest Stable Version Latest Unstable Version Code Coverage @@ -15,7 +14,6 @@ Sponsor me

- ## 特点 1. 支持目前市面多家服务商 @@ -45,7 +43,6 @@ - [创蓝云智](https://www.chuanglan.com/) - [融云](http://www.rongcloud.cn) - [天毅无线](http://www.85hu.com/) -- [阿凡达数据](http://www.avatardata.cn/) - [华为云](https://www.huaweicloud.com/product/msgsms.html) - [网易云信](https://yunxin.163.com/sms) - [云之讯](https://www.ucpaas.com/index.html) @@ -69,14 +66,14 @@ ## 安装 ```shell -$ composer require "overtrue/easy-sms" +composer require "overtrue/easy-sms" ``` **For Laravel notification** 如果你喜欢使用 [Laravel Notification](https://laravel.com/docs/5.8/notifications), 可以考虑直接使用朋友封装的拓展包: -https://github.com/yl/easysms-notification-channel + ## 使用 @@ -204,6 +201,7 @@ $easySms->send(13188888888, [ ## 返回值 由于使用多网关发送,所以返回值为一个数组,结构如下: + ```php [ 'yunpian' => [ @@ -473,6 +471,7 @@ $easySms->send($phone_number, [ 'timestamp' => false, // 是否启用时间戳 ], ``` + ### [百度云](https://cloud.baidu.com/) 短信内容使用 `template` + `data` @@ -535,6 +534,7 @@ $easySms->send($phone_number, [ 'channel' => \Overtrue\EasySms\Gateways\Chuanglanv1Gateway::CHANNEL_NORMAL_CODE, ], ``` + 发送示例: ```php @@ -553,6 +553,7 @@ $easySms->send(18888888888, [ 'channel' => \Overtrue\EasySms\Gateways\Chuanglanv1Gateway::CHANNEL_VARIABLE_CODE, ], ``` + 发送示例: ```php @@ -611,7 +612,6 @@ $easySms->send(18888888888, [ ], ``` - ### [腾讯云 SMS](https://cloud.tencent.com/product/sms) 短信内容使用 `template` + `data` @@ -636,16 +636,6 @@ $easySms->send(18888888888, [ ]); ``` -### [阿凡达数据](http://www.avatardata.cn/) - -短信内容使用 `template` + `data` - -```php - 'avatardata' => [ - 'app_key' => '', // APP KEY - ], -``` - ### [华为云 SMS](https://www.huaweicloud.com/product/msgsms.html) 短信内容使用 `template` + `data` @@ -710,6 +700,7 @@ $easySms->send(18888888888, [ ], ]); ``` + 通知模板短信 ```php @@ -722,7 +713,6 @@ $easySms->send(18888888888, [ ]); ``` - ### [云之讯](https://www.ucpaas.com/index.html) 短信内容使用 `template` + `data` @@ -783,7 +773,9 @@ $easySms->send(18888888888, [ ], ]); ``` + ### [Ucloud](https://www.ucloud.cn/) + 短信使用 `template` + `data` ```php @@ -806,8 +798,8 @@ $easySms->send(18888888888, [ ``` - ### [短信宝](http://www.smsbao.com/) + 短信使用 `content` ```php @@ -825,6 +817,7 @@ $easySms->send(18888888888, [ ``` ### [摩杜云](https://www.moduyun.com/) + 短信使用 `template` + `data` ```php @@ -952,6 +945,7 @@ $easySms->send(18888888888, [ ``` 发送示例: + ```php $easySms->send(18888888888, [ 'content' => '您的验证码为: 6379', @@ -984,6 +978,7 @@ $easySms->send(18888888888, [ ``` 发送示例2: + ```php $easySms->send(18888888888, [ 'template' => 'SMS_123456', // 模板ID @@ -1017,6 +1012,7 @@ $easySms->send(18888888888, [ 'content' => '您的验证码为: 6379', ]); ``` + ## :heart: 支持我 [![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me.svg?raw=true)](https://github.com/sponsors/overtrue) @@ -1029,7 +1025,6 @@ Many thanks to Jetbrains for kindly providing a license for me to work on this a [![](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://www.jetbrains.com/?from=https://github.com/overtrue) - ## PHP 扩展包开发 > 想知道如何从零开始构建 PHP 扩展包? diff --git a/src/Gateways/AvatardataGateway.php b/src/Gateways/AvatardataGateway.php deleted file mode 100644 index 1958cd4..0000000 --- a/src/Gateways/AvatardataGateway.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Overtrue\EasySms\Gateways; - -use Overtrue\EasySms\Contracts\MessageInterface; -use Overtrue\EasySms\Contracts\PhoneNumberInterface; -use Overtrue\EasySms\Exceptions\GatewayErrorException; -use Overtrue\EasySms\Support\Config; -use Overtrue\EasySms\Traits\HasHttpRequest; - -/** - * Class AvatardataGateway. - * - * @see http://www.avatardata.cn/Docs/Api/fd475e40-7809-4be7-936c-5926dd41b0fe - */ -class AvatardataGateway extends Gateway -{ - use HasHttpRequest; - - const ENDPOINT_URL = 'http://v1.avatardata.cn/Sms/Send'; - - const ENDPOINT_FORMAT = 'json'; - - /** - * @param PhoneNumberInterface $to - * @param MessageInterface $message - * @param Config $config - * - * @return array - * - * @throws GatewayErrorException; - */ - public function send(PhoneNumberInterface $to, MessageInterface $message, Config $config) - { - $params = [ - 'mobile' => $to->getNumber(), - 'templateId' => $message->getTemplate($this), - 'param' => implode(',', $message->getData($this)), - 'dtype' => self::ENDPOINT_FORMAT, - 'key' => $config->get('app_key'), - ]; - - $result = $this->get(self::ENDPOINT_URL, $params); - - if ($result['error_code']) { - throw new GatewayErrorException($result['reason'], $result['error_code'], $result); - } - - return $result; - } -} diff --git a/tests/Gateways/AvatardataGatewayTest.php b/tests/Gateways/AvatardataGatewayTest.php deleted file mode 100644 index dbcd43e..0000000 --- a/tests/Gateways/AvatardataGatewayTest.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace Overtrue\EasySms\Tests\Gateways; - -use Overtrue\EasySms\Exceptions\GatewayErrorException; -use Overtrue\EasySms\Gateways\AvatardataGateway; -use Overtrue\EasySms\Message; -use Overtrue\EasySms\PhoneNumber; -use Overtrue\EasySms\Support\Config; -use Overtrue\EasySms\Tests\TestCase; - -class AvatardataGatewayTest extends TestCase -{ - public function testSend() - { - $config = [ - 'app_key' => 'mock-key', - ]; - $gateway = \Mockery::mock(AvatardataGateway::class.'[get]', [$config])->shouldAllowMockingProtectedMethods(); - - $params = [ - 'mobile' => 18888888888, - 'templateId' => 'mock-tpl-id', - 'param' => implode(',', ['1234']), - 'dtype' => AvatardataGateway::ENDPOINT_FORMAT, - 'key' => 'mock-key', - ]; - $gateway->shouldReceive('get')->with(AvatardataGateway::ENDPOINT_URL, $params) - ->andReturn([ - 'reason' => 'Success', - 'error_code' => 0, - ], [ - 'reason' => '错误的请求KEY', - 'error_code' => 10001, - ])->times(2); - - $message = new Message([ - 'content' => 'This is a test message.', - 'template' => 'mock-tpl-id', - 'data' => [ - '1234', - ], - ]); - - $config = new Config($config); - - $this->assertSame([ - 'reason' => 'Success', - 'error_code' => 0, - ], $gateway->send(new PhoneNumber(18888888888), $message, $config)); - - $this->expectException(GatewayErrorException::class); - $this->expectExceptionCode(10001); - $this->expectExceptionMessage('错误的请求KEY'); - - $gateway->send(new PhoneNumber(18888888888), $message, $config); - } -}