Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
数据应用
ThinkLibrary
提交
432c9eb8
T
ThinkLibrary
项目概览
数据应用
/
ThinkLibrary
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
代码片段
项目成员
Pages
T
ThinkLibrary
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
432c9eb8
编写于
9月 21, 2020
作者:
李光春
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- 微信小程序接口增加直播
上级
3606bde7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
624 addition
and
2 deletion
+624
-2
CHANGELOG.md
CHANGELOG.md
+3
-0
src/common.php
src/common.php
+1
-1
src/service/decent/EJiAoFei.php
src/service/decent/EJiAoFei.php
+1
-1
src/service/qiniu/SmsService.php
src/service/qiniu/SmsService.php
+394
-0
src/service/wechat/MiniService.php
src/service/wechat/MiniService.php
+225
-0
未找到文件。
CHANGELOG.md
浏览文件 @
432c9eb8
## v6.0.115 / 2020-09-21
-
微信小程序接口增加直播
## v6.0.114 / 2020-09-16
-
优化鼎信缴费平台充值接口
...
...
src/common.php
浏览文件 @
432c9eb8
...
...
@@ -25,7 +25,7 @@ use DtApp\ThinkLibrary\service\SystemService;
/**
* 定义当前版本
*/
const
VERSION
=
'6.0.11
4
'
;
const
VERSION
=
'6.0.11
5
'
;
if
(
!
function_exists
(
'get_ip_info'
))
{
/**
...
...
src/service/decent/EJiAoFei.php
浏览文件 @
432c9eb8
...
...
@@ -161,7 +161,7 @@ class EJiAoFei extends Service
*/
public
function
gprsChongzhiAdvance
(
string
$orderid
,
string
$account
,
int
$gprs
,
int
$area
,
int
$effecttime
,
int
$validity
,
string
$times
):
self
{
$this
->
method
=
'
queryTXproduct
'
;
$this
->
method
=
'
gprsChongzhiAdvance
'
;
$this
->
param
=
"userid=
{
$this
->
userid
}
&pwd=
{
$this
->
pwd
}
&orderid=
{
$orderid
}
&account=
{
$account
}
&gprs=
{
$gprs
}
&area=
{
$area
}
&effecttime=
{
$effecttime
}
&validity=
{
$validity
}
×=
{
$times
}
"
;
return
$this
;
}
...
...
src/service/qiniu/SmsService.php
0 → 100644
浏览文件 @
432c9eb8
<?php
namespace
DtApp\ThinkLibrary\service\qiniu
;
use
DtApp\ThinkLibrary\exception\DtaException
;
use
DtApp\ThinkLibrary\Service
;
use
Qiniu\Auth
;
use
Qiniu\Http\Client
;
use
think\exception\HttpException
;
/**
* Class SmsService
* @package DtApp\ThinkLibrary\service\qiniu
*/
class
SmsService
extends
Service
{
/**
* @var
*/
private
$accessKey
,
$secretKey
,
$url
,
$method
;
/**
* 需要发送的的参数
* @var
*/
private
$param
=
[];
/**
* 响应内容
* @var
*/
private
$output
;
/**
* @var string
*/
private
$contentType
=
"application/json"
;
/**
* @param string $accessKey
* @return $this
*/
public
function
accessKey
(
string
$accessKey
):
self
{
$this
->
accessKey
=
$accessKey
;
return
$this
;
}
/**
* @param string $secretKey
* @return $this
*/
public
function
secretKey
(
string
$secretKey
):
self
{
$this
->
secretKey
=
$secretKey
;
return
$this
;
}
/**
* 请求参数
* @param array $param
* @return $this
*/
public
function
param
(
array
$param
):
self
{
$this
->
param
=
$param
;
return
$this
;
}
/**
* 发送短信
* https://developer.qiniu.com/sms/api/5897/sms-api-send-message#1
* @return $this
*/
public
function
message
():
self
{
$this
->
url
=
"https://sms.qiniuapi.com/v1/message"
;
$this
->
method
=
"POST"
;
return
$this
;
}
/**
* 发送单条短信
* https://developer.qiniu.com/sms/api/5897/sms-api-send-message#2
* @return $this
*/
public
function
messageSingle
():
self
{
$this
->
url
=
"https://sms.qiniuapi.com/v1/message/single"
;
$this
->
method
=
"POST"
;
return
$this
;
}
/**
* 发送国际/港澳台短信
* https://developer.qiniu.com/sms/api/5897/sms-api-send-message#3
* @return $this
*/
public
function
messageOversea
():
self
{
$this
->
url
=
"https://sms.qiniuapi.com/v1/message/oversea"
;
$this
->
method
=
"POST"
;
return
$this
;
}
/**
* 发送全文本短信(不需要传模版 ID)
* https://developer.qiniu.com/sms/api/5897/sms-api-send-message#3
* @return $this
*/
public
function
messageFulltext
():
self
{
$this
->
url
=
"https://sms.qiniuapi.com/v1/message/fulltext"
;
$this
->
method
=
"POST"
;
return
$this
;
}
/**
* 查询短信发送记录
* https://developer.qiniu.com/sms/api/5852/query-send-sms
* @return $this
*/
public
function
messages
():
self
{
$this
->
url
=
"https://sms.qiniuapi.com/v1/messages"
;
$this
->
method
=
"GET"
;
return
$this
;
}
/**
* 创建签名
* https://developer.qiniu.com/sms/api/5844/sms-api-create-signature
* @return $this
*/
public
function
signature
():
self
{
$this
->
url
=
"https://sms.qiniuapi.com/v1/signature"
;
$this
->
method
=
"POST"
;
return
$this
;
}
/**
* 查询签名
* https://developer.qiniu.com/sms/api/5844/sms-api-create-signature
* @return $this
*/
public
function
signatureQuery
():
self
{
$this
->
url
=
"https://sms.qiniuapi.com/v1/signature"
;
$this
->
method
=
"GET"
;
$this
->
contentType
=
"application/x-www-form-urlencoded"
;
return
$this
;
}
/**
* 查询单个签名信息
* https://developer.qiniu.com/sms/api/5970/query-a-single-signature
* @param $id
* @return $this
* @throws DtaException
*/
public
function
signatureQueryId
(
$id
):
self
{
if
(
empty
(
$id
))
{
throw
new
DtaException
(
'请检查id参数'
);
}
$this
->
url
=
"https://sms.qiniuapi.com/v1/signature/
{
$id
}
"
;
$this
->
method
=
"GET"
;
return
$this
;
}
/**
* 编辑签名
* https://developer.qiniu.com/sms/api/5890/sms-api-edit-signature
* @param $id
* @return $this
* @throws DtaException
*/
public
function
signatureEditId
(
$id
):
self
{
if
(
empty
(
$id
))
{
throw
new
DtaException
(
'请检查id参数'
);
}
$this
->
url
=
"https://sms.qiniuapi.com/v1/signature/
{
$id
}
"
;
$this
->
method
=
"PUT"
;
return
$this
;
}
/**
* 删除签名
* https://developer.qiniu.com/sms/api/5891/sms-api-delete-signature
* @param $id
* @return $this
* @throws DtaException
*/
public
function
signatureDelId
(
$id
):
self
{
if
(
empty
(
$id
))
{
throw
new
DtaException
(
'请检查id参数'
);
}
$this
->
url
=
"https://sms.qiniuapi.com/v1/signature/
{
$id
}
"
;
$this
->
method
=
"DELETE"
;
return
$this
;
}
/**
* 创建模板
* https://developer.qiniu.com/sms/api/5893/sms-api-create-template
* @return $this
*/
public
function
template
():
self
{
$this
->
url
=
"https://sms.qiniuapi.com/v1/template"
;
$this
->
method
=
"POST"
;
return
$this
;
}
/**
* 查询模板
* https://developer.qiniu.com/sms/api/5894/sms-api-query-template
* @return $this
*/
public
function
templateQuery
():
self
{
$this
->
url
=
"https://sms.qiniuapi.com/v1/template"
;
$this
->
method
=
"GET"
;
return
$this
;
}
/**
* 查询单个模版信息
* https://developer.qiniu.com/sms/api/5969/query-a-single-template
* @param $id
* @return $this
* @throws DtaException
*/
public
function
templateQueryId
(
$id
):
self
{
if
(
empty
(
$id
))
{
throw
new
DtaException
(
'请检查id参数'
);
}
$this
->
url
=
"https://sms.qiniuapi.com/v1/template/
{
$id
}
"
;
$this
->
method
=
"GET"
;
return
$this
;
}
/**
* 编辑签名
* https://developer.qiniu.com/sms/api/5895/sms-api-edit-template
* @param $id
* @return $this
* @throws DtaException
*/
public
function
templateEditId
(
$id
):
self
{
if
(
empty
(
$id
))
{
throw
new
DtaException
(
'请检查id参数'
);
}
$this
->
url
=
"https://sms.qiniuapi.com/v1/template/
{
$id
}
"
;
$this
->
method
=
"PUT"
;
return
$this
;
}
/**
* 删除签名
* https://developer.qiniu.com/sms/api/5896/sms-api-delete-template
* @param $id
* @return $this
* @throws DtaException
*/
public
function
templateDelId
(
$id
):
self
{
if
(
empty
(
$id
))
{
throw
new
DtaException
(
'请检查id参数'
);
}
$this
->
url
=
"https://sms.qiniuapi.com/v1/template/
{
$id
}
"
;
$this
->
method
=
"DELETE"
;
return
$this
;
}
/**
* 返回数组数据
* @return array|mixed
* @throws DtaException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public
function
toArray
()
{
//首先检测是否支持curl
if
(
!
extension_loaded
(
"curl"
))
{
throw
new
HttpException
(
404
,
'请开启curl模块!'
);
}
$this
->
http
();
// 正常
if
(
is_array
(
$this
->
output
))
{
return
$this
->
output
;
}
if
(
is_object
(
$this
->
output
))
{
$this
->
output
=
$this
->
object2array
(
$this
->
output
);
return
$this
->
output
;
}
$this
->
output
=
json_decode
(
$this
->
output
,
true
);
return
$this
->
output
;
}
/**
* @param $object
* @return array
*/
private
function
object2array
(
&
$object
)
:
array
{
if
(
is_object
(
$object
))
{
$arr
=
(
array
)(
$object
);
}
else
{
$arr
=
&
$object
;
}
if
(
is_array
(
$arr
))
{
foreach
(
$arr
as
$varName
=>
$varValue
)
{
$arr
[
$varName
]
=
$this
->
object2array
(
$varValue
);
}
}
return
$arr
;
}
/**
* 网络请求
* @return $this
* @throws DtaException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
private
function
http
():
self
{
if
(
empty
(
$this
->
accessKey
))
{
throw
new
DtaException
(
'请检查accessKey参数'
);
}
if
(
empty
(
$this
->
secretKey
))
{
throw
new
DtaException
(
'请检查secretKey参数'
);
}
$headers
=
[
'Authorization'
=>
$this
->
authentication
(),
'Content-Type'
=>
$this
->
contentType
];
$auth
=
new
Auth
(
$this
->
accessKey
,
$this
->
secretKey
);
$recToken
=
$auth
->
authorizationV2
(
$this
->
url
,
$this
->
method
,
json_encode
(
$this
->
param
),
$this
->
contentType
);
$rtcToken
[
'Content-Type'
]
=
$this
->
contentType
;
dump
(
$recToken
);
dump
(
$this
->
url
.
"?"
.
http_build_query
(
$this
->
param
));
$ret
=
Client
::
get
(
$this
->
url
.
"?"
.
http_build_query
(
$this
->
param
),
$recToken
);
dump
(
$ret
);
$this
->
output
=
$ret
->
json
();
return
$this
;
}
/**
* 服务鉴权
* https://developer.qiniu.com/sms/api/5842/sms-api-authentication
* @return string
*/
private
function
authentication
()
{
$url
=
parse_url
(
$this
->
url
);
$data
=
$url
[
'path'
]
??
''
;
if
(
isset
(
$url
[
'query'
]))
{
$data
.
=
'?'
.
$url
[
'query'
];
}
$data
.
=
"
\n
"
;
if
(
isset
(
$this
->
param
)
&&
$this
->
contentType
===
'application/x-www-form-urlencoded'
)
{
$data
.
=
json_encode
(
$this
->
param
);
}
return
$this
->
sign
(
$data
);
}
/**
* @param $data
* @return string
*/
private
function
sign
(
$data
)
{
$sign
=
hash_hmac
(
'sha1'
,
$data
,
$this
->
secretKey
,
true
);
return
"Qiniu "
.
sprintf
(
'%s:%s'
,
$this
->
accessKey
,
$this
->
encode
(
$sign
));
}
/**
* @param $string
* @return string|string[]
*/
private
function
encode
(
$string
)
{
$find
=
[
'+'
,
'/'
];
$replace
=
[
'-'
,
'_'
];
return
str_replace
(
$find
,
$replace
,
base64_encode
(
$string
));
}
}
\ No newline at end of file
src/service/wechat/MiniService.php
浏览文件 @
432c9eb8
...
...
@@ -377,6 +377,231 @@ class MiniService extends Service
return
json_decode
(
$result
,
true
);
}
/**
* 【小程序直播】直播间管理接口 - 创建直播间
* https://developers.weixin.qq.com/miniprogram/dev/framework/liveplayer/studio-api.html#1
* @param array $data
* @return array|bool|mixed|string
* @throws DbException
* @throws DtaException
*/
public
function
broadcastRoomCreate
(
array
$data
=
[])
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"https://api.weixin.qq.com/wxaapi/broadcast/room/create?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
return
HttpService
::
instance
()
->
url
(
$url
)
->
data
(
$data
)
->
post
()
->
toArray
();
}
/**
* 【小程序直播】直播间管理接口 - 获取直播间列表
* https://developers.weixin.qq.com/miniprogram/dev/framework/liveplayer/studio-api.html#2
* @param array $data
* @return array|bool|mixed|string
* @throws DbException
* @throws DtaException
*/
public
function
broadcastGetLiveInfos
(
array
$data
=
[])
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"https://api.weixin.qq.com/wxa/business/getliveinfo?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
return
HttpService
::
instance
()
->
url
(
$url
)
->
data
(
$data
)
->
post
()
->
toArray
();
}
/**
* 【小程序直播】直播间管理接口 - 获取直播间回放
* https://developers.weixin.qq.com/miniprogram/dev/framework/liveplayer/studio-api.html#3
* @param array $data
* @return array|bool|mixed|string
* @throws DbException
* @throws DtaException
*/
public
function
broadcastGetLiveInfo
(
array
$data
=
[])
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"https://api.weixin.qq.com/wxa/business/getliveinfo?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
return
HttpService
::
instance
()
->
url
(
$url
)
->
data
(
$data
)
->
post
()
->
toArray
();
}
/**
* 【小程序直播】直播间管理接口 - 直播间导入商品
* https://developers.weixin.qq.com/miniprogram/dev/framework/liveplayer/studio-api.html#4
* @param array $data
* @return array|bool|mixed|string
* @throws DbException
* @throws DtaException
*/
public
function
broadcastRoomAddGoods
(
array
$data
=
[])
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"https://api.weixin.qq.com/wxaapi/broadcast/room/addgoods?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
return
HttpService
::
instance
()
->
url
(
$url
)
->
data
(
$data
)
->
post
()
->
toArray
();
}
/**
* 【小程序直播】直播商品管理接口 - 商品添加并提审
* https://developers.weixin.qq.com/miniprogram/dev/framework/liveplayer/commodity-api.html#1
* @param array $data
* @return array|bool|mixed|string
* @throws DbException
* @throws DtaException
*/
public
function
broadcastGoodsAdd
(
array
$data
=
[])
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"https://api.weixin.qq.com/wxaapi/broadcast/goods/add?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
return
HttpService
::
instance
()
->
url
(
$url
)
->
data
(
$data
)
->
post
()
->
toArray
();
}
/**
* 【小程序直播】直播商品管理接口 - 撤回审核
* https://developers.weixin.qq.com/miniprogram/dev/framework/liveplayer/commodity-api.html#2
* @param array $data
* @return array|bool|mixed|string
* @throws DbException
* @throws DtaException
*/
public
function
broadcastGoodsResetAudit
(
array
$data
=
[])
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"https://api.weixin.qq.com/wxaapi/broadcast/goods/resetaudit?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
return
HttpService
::
instance
()
->
url
(
$url
)
->
data
(
$data
)
->
post
()
->
toArray
();
}
/**
* 【小程序直播】直播商品管理接口 - 重新提交审核
* https://developers.weixin.qq.com/miniprogram/dev/framework/liveplayer/commodity-api.html#3
* @param array $data
* @return array|bool|mixed|string
* @throws DbException
* @throws DtaException
*/
public
function
broadcastGoodsAudit
(
array
$data
=
[])
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"https://api.weixin.qq.com/wxaapi/broadcast/goods/audit?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
return
HttpService
::
instance
()
->
url
(
$url
)
->
data
(
$data
)
->
post
()
->
toArray
();
}
/**
* 【小程序直播】直播商品管理接口 - 删除商品
* https://developers.weixin.qq.com/miniprogram/dev/framework/liveplayer/commodity-api.html#4
* @param array $data
* @return array|bool|mixed|string
* @throws DbException
* @throws DtaException
*/
public
function
broadcastGoodsDelete
(
array
$data
=
[])
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"https://api.weixin.qq.com/wxaapi/broadcast/goods/delete?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
return
HttpService
::
instance
()
->
url
(
$url
)
->
data
(
$data
)
->
post
()
->
toArray
();
}
/**
* 【小程序直播】直播商品管理接口 - 更新商品
* https://developers.weixin.qq.com/miniprogram/dev/framework/liveplayer/commodity-api.html#5
* @param array $data
* @return array|bool|mixed|string
* @throws DbException
* @throws DtaException
*/
public
function
broadcastGoodsUpdate
(
array
$data
=
[])
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"https://api.weixin.qq.com/wxaapi/broadcast/goods/update?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
return
HttpService
::
instance
()
->
url
(
$url
)
->
data
(
$data
)
->
post
()
->
toArray
();
}
/**
* 【小程序直播】直播商品管理接口 - 获取商品状态
* https://developers.weixin.qq.com/miniprogram/dev/framework/liveplayer/commodity-api.html#6
* @param array $data
* @return array|bool|mixed|string
* @throws DbException
* @throws DtaException
*/
public
function
broadcastGetGoodsWarehouse
(
array
$data
=
[])
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"https://api.weixin.qq.com/wxa/business/getgoodswarehouse?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
return
HttpService
::
instance
()
->
url
(
$url
)
->
data
(
$data
)
->
post
()
->
toArray
();
}
/**
* 【小程序直播】直播商品管理接口 - 获取商品列表
* https://developers.weixin.qq.com/miniprogram/dev/framework/liveplayer/commodity-api.html#7
* @param array $data
* @return array|bool|mixed|string
* @throws DbException
* @throws DtaException
*/
public
function
broadcastGoodsGetAppRoved
(
array
$data
=
[])
{
// 获取数据
$accessToken
=
$this
->
getAccessToken
();
$url
=
"https://api.weixin.qq.com/wxaapi/broadcast/goods/getapproved?access_token=
{
$accessToken
[
'access_token'
]
}
"
;
return
HttpService
::
instance
()
->
url
(
$url
)
->
data
(
$data
)
->
post
()
->
toArray
();
}
/**
* 获取小程序全局唯一后台接口调用凭据(access_token)
* https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/access-token/auth.getAccessToken.html
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录