Commit c532cc2b by HanSon

增加upload media

1 parent 579cba4a
......@@ -306,6 +306,20 @@ $robot->server->setCustomHandler(function(){
- [ ] 消息抽象成每个类
- [ ] 群操作
- [ ] 创建群
- [ ] 把某人踢出群
- [ ] 邀请好友加入群
- [ ] 修改群名称
- [ ] 聊天窗口操作
- [ ] 置顶聊天会话
- [ ] 取消聊天会话指定
- [ ] 好友操作
- [ ] 给好友添加备注
- [ ] 通过好友验证
- [x] 增加消息集合存储
- [ ] 消息发送
......@@ -328,4 +342,4 @@ $robot->server->setCustomHandler(function(){
# 已知bug
* 20% 的几率初始化失败(暂时无解,如清楚问题欢迎PR)
* 30% 的几率初始化失败(暂时无解,如清楚问题欢迎PR)
......@@ -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'));
}
});
......
......@@ -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!');
}
}
......
......@@ -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.wx2.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', [
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!