Commit 04712535 by HanSon

还没修复

1 parent 728e78dc
......@@ -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/843242266304844229.jpg'));
Image::send($message->username, realpath(__DIR__ . '/./../tmp/jpg/5102437722783331610.jpg'));
}
});
......
......@@ -37,7 +37,8 @@ trait UploadAble
'id' => 'WU_FILE_' .static::$mediaCount,
'name' => basename($file),
'type' => $mime,
'lastModifieDate' => date('D M m Y H:i:s').' GMT+0800 (CST)',
// '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)',
'size' => filesize($file),
'mediatype' => $mediaType,
'uploadmediarequest' => json_encode([
......@@ -47,10 +48,10 @@ trait UploadAble
'StartPos' => 0,
'DataLen' => filesize($file),
'MediaType' => 4,
// 'UploadType' => 2,
// 'FromUserName' => myself()->username,
// 'ToUserName' => $username,
// 'FileMd5' => md5_file($file)
'UploadType' => 2,
'FromUserName' => myself()->username,
'ToUserName' => $username,
'FileMd5' => md5_file($file)
], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES),
'webwx_data_ticket' => static::getTicket(),
'pass_ticket' => urldecode(server()->passTicket),
......@@ -61,13 +62,15 @@ 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', [
// 'multipart' => $data
// ]);
// $result = json_decode($result, true);
print_r($data);
print_r($result);
......@@ -96,7 +99,7 @@ trait UploadAble
return $cookies[$key]['Value'];
}
private function dataToMultipart($data)
private static function dataToMultipart($data)
{
$result = [];
......@@ -105,7 +108,10 @@ trait UploadAble
'name' => $key,
'contents' => $item
];
if($key === 'filename') $field['filename'] = basename(static::$file);
if($key === 'filename'){
$field['filename'] = basename(static::$file);
$field['Content-type'] = 'image/jpeg';
}
$result[] = $field;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!