Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
easy-sms
提交
c095c62b
E
easy-sms
项目概览
OpenDocCN
/
easy-sms
通知
3
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
easy-sms
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c095c62b
编写于
12月 29, 2017
作者:
高
高大成
提交者:
安正超
12月 29, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add tianyiwuxian support (#67)
* 添加`天毅无线`的支持 * fix CS. * remove unused import.
上级
7f6a1de2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
96 addition
and
0 deletion
+96
-0
README.md
README.md
+13
-0
src/Gateways/TianyiwuxianGateway.php
src/Gateways/TianyiwuxianGateway.php
+83
-0
未找到文件。
README.md
浏览文件 @
c095c62b
...
...
@@ -46,6 +46,7 @@
-
[
华信短信平台
](
http://www.ipyy.com/
)
-
[
253云通讯(创蓝)
](
https://www.253.com/
)
-
[
融云
](
http://www.rongcloud.cn
)
-
[
天毅无线
](
http://www.85hu.com/
)
## 环境需求
...
...
@@ -391,6 +392,18 @@ $easySms->send(13188888888, $message);
]
```
### [天毅无线](http://www.85hu.com/)
短信内容使用
`content`
```
php
'tianyiwuxian'
=>
[
'username'
=>
''
,
//用户名
'password'
=>
''
,
//密码
'gwid'
=>
''
,
//网关ID
]
```
## License
MIT
src/Gateways/TianyiwuxianGateway.php
0 → 100644
浏览文件 @
c095c62b
<?php
/*
* This file is part of the overtrue/easy-sms.
*
* (c) overtrue <i@overtrue.me>
*
* 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\Exceptions\GatewayErrorException
;
use
Overtrue\EasySms\Support\Config
;
use
Overtrue\EasySms\Traits\HasHttpRequest
;
/**
* Class TianyiwuxianGateway.
*
* @author Darren Gao <realgaodacheng@gmail.com>
*/
class
TianyiwuxianGateway
extends
Gateway
{
use
HasHttpRequest
;
const
ENDPOINT_TEMPLATE
=
'http://jk.106api.cn/sms%s.aspx'
;
const
ENDPOINT_ENCODE
=
'UTF8'
;
const
ENDPOINT_TYPE
=
'send'
;
const
ENDPOINT_FORMAT
=
'json'
;
const
SUCCESS_STATUS
=
'success'
;
const
SUCCESS_CODE
=
'0'
;
/**
* @param array|int|string $to
* @param \Overtrue\EasySms\Contracts\MessageInterface $message
* @param \Overtrue\EasySms\Support\Config $config
*
* @return array
*
* @throws \Overtrue\EasySms\Exceptions\GatewayErrorException;
*/
public
function
send
(
$to
,
MessageInterface
$message
,
Config
$config
)
{
$endpoint
=
$this
->
buildEndpoint
();
$params
=
[
'gwid'
=>
$config
->
get
(
'gwid'
),
'type'
=>
self
::
ENDPOINT_TYPE
,
'rece'
=>
self
::
ENDPOINT_FORMAT
,
'mobile'
=>
$to
,
'message'
=>
$message
->
getContent
(),
'username'
=>
$config
->
get
(
'username'
),
'password'
=>
strtoupper
(
md5
(
$config
->
get
(
'password'
))),
];
$result
=
$this
->
post
(
$endpoint
,
$params
);
$result
=
json_decode
(
$result
,
true
);
if
(
self
::
SUCCESS_STATUS
!==
$result
[
'returnstatus'
]
||
self
::
SUCCESS_CODE
!==
$result
[
'code'
])
{
throw
new
GatewayErrorException
(
$result
[
'remark'
],
$result
[
'code'
]);
}
return
$result
;
}
/**
* Build endpoint url.
*
* @return string
*/
protected
function
buildEndpoint
()
{
return
sprintf
(
self
::
ENDPOINT_TEMPLATE
,
self
::
ENDPOINT_ENCODE
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录