Commit 04712535 by HanSon

还没修复

1 parent 728e78dc
...@@ -20,7 +20,7 @@ $robot = new Robot([ ...@@ -20,7 +20,7 @@ $robot = new Robot([
$robot->server->setMessageHandler(function($message){ $robot->server->setMessageHandler(function($message){
/** @var $message Message */ /** @var $message Message */
if($message->content === '测试图片'){ 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 ...@@ -37,7 +37,8 @@ trait UploadAble
'id' => 'WU_FILE_' .static::$mediaCount, 'id' => 'WU_FILE_' .static::$mediaCount,
'name' => basename($file), 'name' => basename($file),
'type' => $mime, '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), 'size' => filesize($file),
'mediatype' => $mediaType, 'mediatype' => $mediaType,
'uploadmediarequest' => json_encode([ 'uploadmediarequest' => json_encode([
...@@ -47,10 +48,10 @@ trait UploadAble ...@@ -47,10 +48,10 @@ trait UploadAble
'StartPos' => 0, 'StartPos' => 0,
'DataLen' => filesize($file), 'DataLen' => filesize($file),
'MediaType' => 4, 'MediaType' => 4,
// 'UploadType' => 2, 'UploadType' => 2,
// 'FromUserName' => myself()->username, 'FromUserName' => myself()->username,
// 'ToUserName' => $username, 'ToUserName' => $username,
// 'FileMd5' => md5_file($file) 'FileMd5' => md5_file($file)
], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES), ], JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES),
'webwx_data_ticket' => static::getTicket(), 'webwx_data_ticket' => static::getTicket(),
'pass_ticket' => urldecode(server()->passTicket), 'pass_ticket' => urldecode(server()->passTicket),
...@@ -61,13 +62,15 @@ trait UploadAble ...@@ -61,13 +62,15 @@ trait UploadAble
// 'filename' => curl_file_create($file, $mime, basename($file)) // 'filename' => curl_file_create($file, $mime, basename($file))
]; ];
$data = static::dataToMultipart($data); // $data = static::dataToMultipart($data);
$result = http()->post($url, $data, true); $result = http()->post($url, $data, true);
// $result = http()->request($url, 'post', [ // $result = http()->request($url, 'post', [
// 'multipart' => $data // 'multipart' => $data
// ]); // ]);
// $result = json_decode($result, true);
print_r($data); print_r($data);
print_r($result); print_r($result);
...@@ -96,7 +99,7 @@ trait UploadAble ...@@ -96,7 +99,7 @@ trait UploadAble
return $cookies[$key]['Value']; return $cookies[$key]['Value'];
} }
private function dataToMultipart($data) private static function dataToMultipart($data)
{ {
$result = []; $result = [];
...@@ -105,7 +108,10 @@ trait UploadAble ...@@ -105,7 +108,10 @@ trait UploadAble
'name' => $key, 'name' => $key,
'contents' => $item '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; $result[] = $field;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!