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 579cba4a
authored
Jan 12, 2017
by
hanccc
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
无语了。。。
1 parent
04712535
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
18 deletions
example/image.php
src/Core/Server.php
src/Message/UploadAble.php
example/image.php
View file @
579cba4
...
...
@@ -20,7 +20,7 @@ $robot = new Robot([
$robot
->
server
->
setMessageHandler
(
function
(
$message
){
/** @var $message Message */
if
(
$message
->
content
===
'测试图片'
){
Image
::
send
(
$message
->
username
,
realpath
(
__DIR__
.
'/./../tmp/jpg/
5102437722783331610
.jpg'
));
Image
::
send
(
$message
->
username
,
realpath
(
__DIR__
.
'/./../tmp/jpg/
9031924810002714257
.jpg'
));
}
});
...
...
src/Core/Server.php
View file @
579cba4
...
...
@@ -196,17 +196,18 @@ class Server
{
$content
=
http
()
->
get
(
$this
->
redirectUri
);
$crawler
=
new
Crawler
(
$content
);
$this
->
skey
=
$crawler
->
filter
(
'error skey'
)
->
text
();
$this
->
sid
=
$crawler
->
filter
(
'error wxsid'
)
->
text
();
$this
->
uin
=
$crawler
->
filter
(
'error wxuin'
)
->
text
();
$this
->
passTicket
=
$crawler
->
filter
(
'error pass_ticket'
)
->
text
();
$data
=
(
array
)
simplexml_load_string
(
$content
,
'SimpleXMLElement'
,
LIBXML_NOCDATA
);
$this
->
skey
=
$data
[
'skey'
];
$this
->
sid
=
$data
[
'wxsid'
];
$this
->
uin
=
$data
[
'wxuin'
];
$this
->
passTicket
=
$data
[
'pass_ticket'
];
if
(
in_array
(
''
,
[
$this
->
skey
,
$this
->
sid
,
$this
->
uin
,
$this
->
passTicket
])){
throw
new
\Exception
(
'[ERROR] login fail!'
);
}
$this
->
deviceId
=
'e'
.
strval
(
random_int
(
100000000000000
,
999999999999999
)
);
$this
->
deviceId
=
'e'
.
substr
(
mt_rand
()
.
mt_rand
(),
1
,
15
);
$this
->
baseRequest
=
[
'Uin'
=>
intval
(
$this
->
uin
),
...
...
@@ -220,7 +221,7 @@ class Server
protected
function
init
(
$first
=
true
)
{
$url
=
sprintf
(
self
::
BASE_URI
.
'/webwxinit?r=%
i&lang=en_US&pass_ticket=%s&skey=%s'
,
time
(),
$this
->
passTicket
,
$this
->
skey
);
$url
=
sprintf
(
self
::
BASE_URI
.
'/webwxinit?r=%
d'
,
time
()
);
$content
=
http
()
->
json
(
$url
,
[
'BaseRequest'
=>
$this
->
baseRequest
...
...
@@ -234,8 +235,10 @@ class Server
$this
->
initContactList
(
$result
[
'ContactList'
]);
if
(
$result
[
'BaseResponse'
][
'Ret'
]
!=
0
){
// Log::echo('init fail!');
throw
new
Exception
(
'[ERROR] init fail!'
);
// print_r($this->baseRequest);
Console
::
log
(
'[ERROR] init fail!'
);
// throw new Exception('[ERROR] init fail!');
}
}
...
...
src/Message/UploadAble.php
View file @
579cba4
...
...
@@ -54,7 +54,7 @@ trait UploadAble
'FileMd5'
=>
md5_file
(
$file
)
],
JSON_UNESCAPED_UNICODE
|
JSON_UNESCAPED_SLASHES
),
'webwx_data_ticket'
=>
static
::
getTicket
(),
'pass_ticket'
=>
urldecode
(
server
()
->
passTicket
),
'pass_ticket'
=>
(
server
()
->
passTicket
),
// 'filename' => "@{$file};filename=".basename($file),
// 'filename' => file_get_contents($file),
'filename'
=>
fopen
(
$file
,
'r'
),
...
...
@@ -63,13 +63,12 @@ trait UploadAble
];
// $data = static::dataToMultipart($data);
$result
=
http
()
->
post
(
$url
,
$data
,
true
);
//
$result = http()->post($url, $data, true);
// $result = http()->request($url, 'post', [
// 'multipart' => $data
// ]);
// $result = json_decode($result, true);
$result
=
http
()
->
request
(
$url
,
'post'
,
[
'multipart'
=>
$data
]);
$result
=
json_decode
(
$result
,
true
);
print_r
(
$data
);
print_r
(
$result
);
...
...
@@ -110,7 +109,7 @@ trait UploadAble
];
if
(
$key
===
'filename'
){
$field
[
'filename'
]
=
basename
(
static
::
$file
);
$field
[
'Content-type'
]
=
'image/jpeg
'
;
// $field['Content-type'] = 'application/octet-stream
';
}
$result
[]
=
$field
;
}
...
...
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