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 c532cc2b
authored
Jan 12, 2017
by
HanSon
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
增加upload media
1 parent
579cba4a
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
8 deletions
README.md
example/image.php
src/Core/Server.php
src/Message/UploadAble.php
README.md
View file @
c532cc2
...
...
@@ -306,6 +306,20 @@ $robot->server->setCustomHandler(function(){
-
[
]
消息抽象成每个类
-
[
]
群操作
-
[
]
创建群
-
[
]
把某人踢出群
-
[
]
邀请好友加入群
-
[
]
修改群名称
-
[
]
聊天窗口操作
-
[
]
置顶聊天会话
-
[
]
取消聊天会话指定
-
[
]
好友操作
-
[
]
给好友添加备注
-
[
]
通过好友验证
-
[
x
]
增加消息集合存储
-
[
]
消息发送
...
...
@@ -328,4 +342,4 @@ $robot->server->setCustomHandler(function(){
# 已知bug
*
2
0% 的几率初始化失败(暂时无解,如清楚问题欢迎PR)
*
3
0% 的几率初始化失败(暂时无解,如清楚问题欢迎PR)
example/image.php
View file @
c532cc2
...
...
@@ -20,7 +20,8 @@ $robot = new Robot([
$robot
->
server
->
setMessageHandler
(
function
(
$message
){
/** @var $message Message */
if
(
$message
->
content
===
'测试图片'
){
Image
::
send
(
$message
->
username
,
realpath
(
__DIR__
.
'/./../tmp/jpg/9031924810002714257.jpg'
));
// https://wx2.qq.com/cgi-bin/mmwebwx-bin
Image
::
send
(
$message
->
username
,
realpath
(
__DIR__
.
'/./../tmp/jpg/1547651860337387181.jpg'
));
}
});
...
...
src/Core/Server.php
View file @
c532cc2
...
...
@@ -111,8 +111,8 @@ class Server
$content
=
http
()
->
get
(
'https://login.weixin.qq.com/jslogin'
,
[
'appid'
=>
'wx782c26e4c19acffb'
,
'fun'
=>
'new'
,
'lang'
=>
'zh_CN'
,
'_'
=>
time
()
*
1000
.
random_int
(
1
,
999
)
//
'lang' => 'zh_CN',
//
'_' => time() * 1000 . random_int(1, 999)
]);
preg_match
(
'/window.QRLogin.code = (\d+); window.QRLogin.uuid = \"(\S+?)\"/'
,
$content
,
$matches
);
...
...
@@ -168,6 +168,7 @@ class Server
case
'200'
:
preg_match
(
'/window.redirect_uri="(\S+?)";/'
,
$content
,
$matches
);
$this
->
redirectUri
=
$matches
[
1
]
.
'&fun=new'
;
Console
::
log
(
'登录URL:'
.
$this
->
redirectUri
);
return
;
case
'408'
:
Console
::
log
(
'[ERROR] login timeout. please try 1 second later.'
);
...
...
@@ -237,7 +238,7 @@ class Server
if
(
$result
[
'BaseResponse'
][
'Ret'
]
!=
0
){
// print_r($this->baseRequest);
Console
::
log
(
'
[ERROR] init fail!'
);
Console
::
log
(
'
init URL:'
.
$url
);
// throw new Exception('[ERROR] init fail!');
}
}
...
...
src/Message/UploadAble.php
View file @
c532cc2
...
...
@@ -27,7 +27,7 @@ trait UploadAble
*/
public
static
function
uploadMedia
(
$username
,
$file
)
{
$url
=
'https://file.wx.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json'
;
$url
=
'https://file.wx
2
.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json'
;
static
::
$mediaCount
=
++
static
::
$mediaCount
;
static
::
$file
=
$file
;
...
...
@@ -38,7 +38,7 @@ trait UploadAble
'name'
=>
basename
(
$file
),
'type'
=>
$mime
,
// 'lastModifieDate' => gmdate('D M d Y H:i:s', filemtime($file) ).' GMT+0800 (CST)',
'lastModifieDate'
=>
date
(
'D M d Y H:i:s'
,
filemtime
(
$file
))
.
' GMT+0800
(CST)'
,
'lastModifieDate'
=>
gmdate
(
'D M d Y H:i:s TO'
,
filemtime
(
$file
))
.
'
(CST)'
,
'size'
=>
filesize
(
$file
),
'mediatype'
=>
$mediaType
,
'uploadmediarequest'
=>
json_encode
([
...
...
@@ -62,7 +62,7 @@ trait UploadAble
// 'filename' => curl_file_create($file, $mime, basename($file))
];
//
$data = static::dataToMultipart($data);
$data
=
static
::
dataToMultipart
(
$data
);
// $result = http()->post($url, $data, true);
$result
=
http
()
->
request
(
$url
,
'post'
,
[
...
...
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