Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
数据应用
ThinkLibrary
提交
25b5d7e4
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 搜索 >>
提交
25b5d7e4
编写于
9月 08, 2020
作者:
李光春
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
- 更新微信公众平台的分享接口
上级
b3cd7645
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
27 addition
and
16 deletion
+27
-16
CHANGELOG.md
CHANGELOG.md
+3
-0
src/ApiController.php
src/ApiController.php
+3
-3
src/common.php
src/common.php
+1
-1
src/service/wechat/WebAppService.php
src/service/wechat/WebAppService.php
+20
-12
未找到文件。
CHANGELOG.md
浏览文件 @
25b5d7e4
## v6.0.111 / 2020-09-08
-
更新微信公众平台的分享接口
## v6.0.110 / 2020-09-06
-
更新拼多多 多客接口
...
...
src/ApiController.php
浏览文件 @
25b5d7e4
...
...
@@ -115,7 +115,7 @@ class ApiController extends stdClass
* @param string $name 参数名
* @return $this
*/
public
function
setAesMd5
(
$name
=
'sniff_h5'
)
public
function
setAesMd5
(
$name
=
'sniff_h5'
)
:
self
{
$value
=
config
(
"dtapp.md5.
{
$name
}
"
);
$this
->
aes_md5
=
$value
;
...
...
@@ -126,7 +126,7 @@ class ApiController extends stdClass
* iv
* @return $this
*/
private
function
setAesMd5Iv
()
private
function
setAesMd5Iv
()
:
self
{
$value
=
config
(
"dtapp.md5.bcw"
);
$this
->
aes_md5_iv
=
$value
;
...
...
@@ -169,7 +169,7 @@ class ApiController extends stdClass
* @param mixed $two 回调引用参数2
* @return boolean
*/
public
function
callback
(
$name
,
&
$one
=
[],
&
$two
=
[])
public
function
callback
(
$name
,
&
$one
=
[],
&
$two
=
[])
:
bool
{
if
(
is_callable
(
$name
))
{
return
call_user_func
(
$name
,
$this
,
$one
,
$two
);
...
...
src/common.php
浏览文件 @
25b5d7e4
...
...
@@ -25,7 +25,7 @@ use DtApp\ThinkLibrary\service\SystemService;
/**
* 定义当前版本
*/
const
VERSION
=
'6.0.11
0
'
;
const
VERSION
=
'6.0.11
1
'
;
if
(
!
function_exists
(
'get_ip_info'
))
{
/**
...
...
src/service/wechat/WebAppService.php
浏览文件 @
25b5d7e4
...
...
@@ -109,7 +109,7 @@ class WebAppService extends Service
* @param string $appId
* @return $this
*/
public
function
appId
(
string
$appId
)
public
function
appId
(
string
$appId
)
:
self
{
$this
->
app_id
=
$appId
;
return
$this
;
...
...
@@ -120,7 +120,7 @@ class WebAppService extends Service
* @param string $appSecret
* @return $this
*/
public
function
appSecret
(
string
$appSecret
)
public
function
appSecret
(
string
$appSecret
)
:
self
{
$this
->
app_secret
=
$appSecret
;
return
$this
;
...
...
@@ -130,7 +130,7 @@ class WebAppService extends Service
* 获取配置信息
* @return $this
*/
private
function
getConfig
()
private
function
getConfig
()
:
self
{
$this
->
cache
=
config
(
'dtapp.wechat.webapp.cache'
);
$this
->
app_id
=
config
(
'dtapp.wechat.webapp.app_id'
);
...
...
@@ -159,7 +159,7 @@ class WebAppService extends Service
* @return $this
* @throws DtaException
*/
public
function
scope
(
string
$scope
)
public
function
scope
(
string
$scope
)
:
self
{
if
(
$scope
===
"snsapi_base"
)
{
$this
->
scope
=
$scope
;
...
...
@@ -176,7 +176,7 @@ class WebAppService extends Service
* @param string $state
* @return $this
*/
public
function
state
(
string
$state
)
public
function
state
(
string
$state
)
:
self
{
$this
->
state
=
$state
;
return
$this
;
...
...
@@ -187,7 +187,7 @@ class WebAppService extends Service
* @param string $cache
* @return $this
*/
public
function
cache
(
string
$cache
)
public
function
cache
(
string
$cache
)
:
self
{
$this
->
cache
=
$cache
;
return
$this
;
...
...
@@ -298,11 +298,12 @@ class WebAppService extends Service
/**
* 分享
* @param string $url
* @return array
* @throws DbException
* @throws DtaException
*/
public
function
share
()
public
function
share
(
$url
=
''
)
{
if
(
empty
(
$this
->
app_id
))
{
$this
->
getConfig
();
...
...
@@ -331,9 +332,11 @@ class WebAppService extends Service
throw
new
DtaException
(
'accessToken已过期'
);
}
}
// 注意 URL 一定要动态获取,不能 hardcode.
$protocol
=
((
!
empty
(
$_SERVER
[
'HTTPS'
])
&&
$_SERVER
[
'HTTPS'
]
!==
'off'
)
||
$_SERVER
[
'SERVER_PORT'
]
==
443
)
?
"https://"
:
"http://"
;
$url
=
"
$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]
"
;
if
(
empty
(
$url
))
{
// 注意 URL 一定要动态获取,不能 hardcode.
$protocol
=
((
!
empty
(
$_SERVER
[
'HTTPS'
])
&&
$_SERVER
[
'HTTPS'
]
!==
'off'
)
||
$_SERVER
[
'SERVER_PORT'
]
===
443
)
?
"https://"
:
"http://"
;
$url
=
"
$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]
"
;
}
$timestamp
=
time
();
$nonceStr
=
$this
->
createNonceStr
();
// 获得jsapi_ticket之后,就可以生成JS-SDK权限验证的签名了。
...
...
@@ -350,6 +353,11 @@ class WebAppService extends Service
];
}
/**
* @param int $length
* @return string
* @throws \Exception
*/
private
function
createNonceStr
(
$length
=
16
)
{
$chars
=
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
;
...
...
@@ -610,7 +618,7 @@ class WebAppService extends Service
}
$this
->
grant_type
=
"client_credential"
;
if
(
$this
->
cache
==
"file"
)
{
if
(
$this
->
cache
==
=
"file"
)
{
// 文件名
$file
=
"
{
$this
->
app
->
getRootPath
()
}
runtime/
{
$this
->
app_id
}
_access_token.json"
;
// 获取数据
...
...
@@ -669,7 +677,7 @@ class WebAppService extends Service
return
$accessToken
;
}
if
(
$this
->
cache
==
"mysql"
)
{
if
(
$this
->
cache
==
=
"mysql"
)
{
$access_token
=
[];
// 文件名
$file
=
"
{
$this
->
app_id
}
_access_token"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录