Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
hfpp2012
/
vbot
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 174552dd
authored
Dec 07, 2016
by
HanSon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
UUid方法
1 parent
76bd6189
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
6 deletions
src/Robot.php
test/test.php
src/Robot.php
View file @
174552d
...
@@ -29,22 +29,33 @@ class Robot
...
@@ -29,22 +29,33 @@ class Robot
$this
->
client
=
new
Client
();
$this
->
client
=
new
Client
();
}
}
/**
* 获取UUID
* @throws \Exception
*/
public
function
getUuid
()
public
function
getUuid
()
{
{
$
response
=
$this
->
client
->
get
(
'https://login.weixin.qq.com/jslogin'
,
[
$
content
=
$this
->
client
->
get
(
'https://login.weixin.qq.com/jslogin'
,
[
'query'
=>
[
'query'
=>
[
'appid'
=>
'wx782c26e4c19acffb'
,
'appid'
=>
'wx782c26e4c19acffb'
,
'fun'
=>
'new'
,
'fun'
=>
'new'
,
'lang'
=>
'zh_CN'
,
'lang'
=>
'zh_CN'
,
'_'
=>
time
()
*
1000
.
random_int
(
1
,
999
)
'_'
=>
time
()
*
1000
.
random_int
(
1
,
999
)
]
]
]);
])
->
getBody
()
->
getContents
();
$content
=
$response
->
getBody
()
->
getContents
();
preg_match
(
'/window.QRLogin.code = (\d+); window.QRLogin.uuid = \"(\S+?)\"/'
,
$content
,
$matches
);
preg_match
(
'/window.QRLogin.code = (\d+); window.QRLogin.uuid = \"(\S+?)\"/'
,
$content
,
$matches
);
return
$matches
;
if
(
!
$matches
){
throw
new
\Exception
(
'获取UUID失败'
);
}
$this
->
uuid
=
$matches
[
2
];
}
public
function
__get
(
$value
)
{
return
$this
->
$value
;
}
}
}
}
\ No newline at end of file
\ No newline at end of file
test/test.php
View file @
174552d
...
@@ -9,4 +9,5 @@
...
@@ -9,4 +9,5 @@
require_once
__DIR__
.
'./../vendor/autoload.php'
;
require_once
__DIR__
.
'./../vendor/autoload.php'
;
$robot
=
new
\Hanson\Robot\Robot
();
$robot
=
new
\Hanson\Robot\Robot
();
print_r
(
$robot
->
getUuid
());
\ No newline at end of file
\ No newline at end of file
$robot
->
getUuid
();
echo
$robot
->
uuid
;
\ No newline at end of file
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment