Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
395cf1f7
Commit
395cf1f7
authored
Nov 13, 2018
by
zhuwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微信
parent
1613d4b7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
3 deletions
+39
-3
WxCallbackUntils.php
application/api/untils/WxCallbackUntils.php
+22
-0
WxAuthorization.php
application/index/controller/WxAuthorization.php
+15
-3
Basic.php
application/index/extend/Basic.php
+2
-0
No files found.
application/api/untils/WxCallbackUntils.php
View file @
395cf1f7
...
...
@@ -39,6 +39,13 @@ class WxCallbackUntils
header
(
"Location:"
.
$url
);
}
public
function
getWxCodesnSapiBase
(
$redirect_url
)
{
$redirect_url
=
urlencode
(
$redirect_url
);
$url
=
"https://open.weixin.qq.com/connect/oauth2/authorize?appid="
.
$this
->
appId
.
"&redirect_uri="
.
$redirect_url
.
"&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
;
header
(
"Location:"
.
$url
);
}
/**
* 获取access_token
...
...
@@ -90,6 +97,21 @@ class WxCallbackUntils
return
$data
;
}
/**
* 获取用户信息
* @param $code
* @return array
*/
public
function
getUserOpenId
(
$code
)
{
$access_token_info
=
$this
->
getAccessTokenByCode
(
$code
);
$access_token_info
=
json_decode
(
$access_token_info
);
$open_id
=
$access_token_info
->
openid
;
return
$open_id
;
}
public
function
curl
(
$url
,
$data
=
[])
{
$ch
=
curl_init
();
...
...
application/index/controller/WxAuthorization.php
View file @
395cf1f7
...
...
@@ -21,6 +21,7 @@ class WxAuthorization extends Basic
public
function
__construct
()
{
parent
::
__construct
();
$this
->
_wxApi
=
new
WxCallbackUntils
();
$this
->
url
=
CURRENT_URL
.
"/index/getWxInfo"
;
}
...
...
@@ -50,12 +51,23 @@ class WxAuthorization extends Basic
public
function
getWxInfoV2
()
{
$code
=
empty
(
$_GET
[
'code'
])
?
null
:
$_GET
[
'code'
];
if
(
!
$code
)
{
$this
->
_wxApi
->
getWxCode
(
CURRENT_URL
.
"/index/getWxInfoV2"
);
$this
->
_wxApi
->
getWxCode
snSapiBase
(
CURRENT_URL
.
"/index/getWxInfoV2"
);
}
else
{
$userInfo
=
$this
->
_wxApi
->
getUserInfoByAccessToken
(
$code
);
dump
(
$userInfo
);
$userInfo
=
$this
->
_wxApi
->
getUserOpenId
(
$code
);
$data
=
[
'id'
=>
'2'
,
'housename'
=>
'怡华苑路304号'
,
'user_tel'
=>
'13918937741'
,
'user_name'
=>
'于盼盼'
,
'share'
=>
'1'
,
'client'
=>
'b'
,
];
$this
->
assign
(
'data'
,
json_encode
(
$data
));
return
view
(
"share_detail"
);
}
}
...
...
application/index/extend/Basic.php
View file @
395cf1f7
...
...
@@ -64,6 +64,7 @@ class Basic extends Controller
'index/getAllDisc'
,
'index/getAgentGroupSite'
,
'index/getRandKingList'
,
'index/getWxInfoV2'
,
);
/**
...
...
@@ -77,6 +78,7 @@ class Basic extends Controller
*/
public
function
__construct
(
Request
$request
=
null
)
{
parent
::
__construct
();
// CORS 跨域 Options 检测响应
$this
->
corsOptionsHandler
();
// 输入对象
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment