Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jcy2004x
ShopXO
提交
94968791
ShopXO
项目概览
jcy2004x
/
ShopXO
与 Fork 源项目一致
Fork自
纵之格 / ShopXO
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
94968791
编写于
5月 24, 2019
作者:
D
devil_gong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
微信授权
上级
3d9bce95
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
79 addition
and
3 deletion
+79
-3
application/plugins/view/weixinwebauthorization/admin/admin/index.html
...lugins/view/weixinwebauthorization/admin/admin/index.html
+10
-0
application/plugins/view/weixinwebauthorization/admin/admin/saveinfo.html
...ins/view/weixinwebauthorization/admin/admin/saveinfo.html
+5
-0
application/plugins/weixinwebauthorization/index/Auth.php
application/plugins/weixinwebauthorization/index/Auth.php
+64
-3
未找到文件。
application/plugins/view/weixinwebauthorization/admin/admin/index.html
浏览文件 @
94968791
...
@@ -19,6 +19,16 @@
...
@@ -19,6 +19,16 @@
{{/if}}
{{/if}}
</div>
</div>
</div>
</div>
<div
class=
"items"
>
<label>
AppSecret
</label>
<div>
{{if !empty($data['secret'])}}
{{$data.secret}}
{{else /}}
未填写
{{/if}}
</div>
</div>
<div
class=
"items"
>
<div
class=
"items"
>
<label>
授权方式
</label>
<label>
授权方式
</label>
<div>
<div>
...
...
application/plugins/view/weixinwebauthorization/admin/admin/saveinfo.html
浏览文件 @
94968791
...
@@ -15,6 +15,11 @@
...
@@ -15,6 +15,11 @@
<input
type=
"text"
name=
"appid"
placeholder=
"appid"
maxlength=
"30"
data-validation-message=
"appid格式最多 30 个字符"
class=
"am-radius"
{{
if
!
empty
($
data
['
appid
'])}}
value=
"{{$data.appid}}"
{{/
if
}}
/>
<input
type=
"text"
name=
"appid"
placeholder=
"appid"
maxlength=
"30"
data-validation-message=
"appid格式最多 30 个字符"
class=
"am-radius"
{{
if
!
empty
($
data
['
appid
'])}}
value=
"{{$data.appid}}"
{{/
if
}}
/>
</div>
</div>
<div
class=
"am-form-group"
>
<label>
secret
<span
class=
"am-form-group-label-tips"
>
公众号/服务号AppSecret
</span></label>
<input
type=
"text"
name=
"secret"
placeholder=
"secret"
maxlength=
"60"
data-validation-message=
"secret格式最多 60 个字符"
class=
"am-radius"
{{
if
!
empty
($
data
['
secret
'])}}
value=
"{{$data.secret}}"
{{/
if
}}
/>
</div>
<div
class=
"am-form-group"
>
<div
class=
"am-form-group"
>
<label>
授权方式
<span
class=
"am-form-group-label-tips"
>
默认 静默授权方式
</span></label>
<label>
授权方式
<span
class=
"am-form-group-label-tips"
>
默认 静默授权方式
</span></label>
<div>
<div>
...
...
application/plugins/weixinwebauthorization/index/Auth.php
浏览文件 @
94968791
...
@@ -30,7 +30,7 @@ class Auth extends Controller
...
@@ -30,7 +30,7 @@ class Auth extends Controller
* @datetime 2019-02-07T08:21:54+0800
* @datetime 2019-02-07T08:21:54+0800
* @param [array] $params [输入参数]
* @param [array] $params [输入参数]
*/
*/
public
function
i
ndex
(
$params
=
[])
public
function
I
ndex
(
$params
=
[])
{
{
$ret
=
PluginsService
::
PluginsData
(
'weixinwebauthorization'
);
$ret
=
PluginsService
::
PluginsData
(
'weixinwebauthorization'
);
if
(
$ret
[
'code'
]
==
0
)
if
(
$ret
[
'code'
]
==
0
)
...
@@ -49,7 +49,7 @@ class Auth extends Controller
...
@@ -49,7 +49,7 @@ class Auth extends Controller
$auth_type
=
(
isset
(
$ret
[
'data'
][
'auth_type'
])
&&
$ret
[
'data'
][
'auth_type'
]
==
1
)
?
'snsapi_userinfo'
:
'snsapi_base'
;
$auth_type
=
(
isset
(
$ret
[
'data'
][
'auth_type'
])
&&
$ret
[
'data'
][
'auth_type'
]
==
1
)
?
'snsapi_userinfo'
:
'snsapi_base'
;
// 授权code
// 授权code
$url
=
'https://open.weixin.qq.com/connect/oauth2/authorize?appid=
4444
&redirect_uri='
.
$redirect_uri
.
'&response_type=code&scope='
.
$auth_type
.
'&state=login#wechat_redirect'
;
$url
=
'https://open.weixin.qq.com/connect/oauth2/authorize?appid=
'
.
$ret
[
'data'
][
'appid'
]
.
'
&redirect_uri='
.
$redirect_uri
.
'&response_type=code&scope='
.
$auth_type
.
'&state=login#wechat_redirect'
;
return
redirect
(
$url
);
return
redirect
(
$url
);
}
else
{
}
else
{
$this
->
assign
(
'msg'
,
$ret
[
'msg'
]);
$this
->
assign
(
'msg'
,
$ret
[
'msg'
]);
...
@@ -65,7 +65,7 @@ class Auth extends Controller
...
@@ -65,7 +65,7 @@ class Auth extends Controller
* @datetime 2019-02-07T08:21:54+0800
* @datetime 2019-02-07T08:21:54+0800
* @param [array] $params [输入参数]
* @param [array] $params [输入参数]
*/
*/
public
function
c
allback
(
$params
=
[])
public
function
C
allback
(
$params
=
[])
{
{
// 参数校验
// 参数校验
if
(
empty
(
$params
[
'code'
]))
if
(
empty
(
$params
[
'code'
]))
...
@@ -73,11 +73,72 @@ class Auth extends Controller
...
@@ -73,11 +73,72 @@ class Auth extends Controller
$this
->
assign
(
'msg'
,
'授权code为空'
);
$this
->
assign
(
'msg'
,
'授权code为空'
);
return
$this
->
fetch
(
'public/tips_error'
);
return
$this
->
fetch
(
'public/tips_error'
);
}
}
// 本地获取access_token
// 远程获取access_token
$ret
=
$this
->
RemoteAccessToken
(
$params
);
echo
'<pre>'
;
echo
'<pre>'
;
print_r
(
$params
);
print_r
(
$params
);
echo
__MY_VIEW_URL__
;
echo
__MY_VIEW_URL__
;
}
}
/**
* 获取access_token
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-05-24
* @desc description
* @param array $params [description]
*/
private
function
AccessToken
(
$params
=
[])
{
}
/**
* 远程获取access_token
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-05-24
* @desc description
* @param array $params [description]
*/
private
function
RemoteAccessToken
(
$params
=
[])
{
$ret
=
PluginsService
::
PluginsData
(
'weixinwebauthorization'
);
if
(
$ret
[
'code'
]
==
0
)
{
// 参数校验
if
(
empty
(
$ret
[
'data'
][
'appid'
]))
{
return
DataReturn
(
'appid未配置'
,
-
1
);
}
if
(
empty
(
$ret
[
'data'
][
'secret'
]))
{
return
DataReturn
(
'secret未配置'
,
-
1
);
}
if
(
empty
(
$params
[
'code'
]))
{
return
DataReturn
(
'code授权码为空'
,
-
1
);
}
// 获取access_token
$url
=
'https://api.weixin.qq.com/sns/oauth2/access_token?appid='
.
$ret
[
'data'
][
'appid'
]
.
'&secret='
.
$ret
[
'data'
][
'secret'
]
.
'&code='
.
$params
[
'code'
]
.
'&grant_type=authorization_code'
;
$data
=
json_decode
(
file_get_contents
(
$url
),
true
);
echo
'<pre>'
;
print_r
(
$data
);
die
;
}
else
{
return
DataReturn
(
$ret
[
'msg'
],
-
1
);
}
}
}
}
?>
?>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录