Commit 579cba4a by hanccc

无语了。。。

1 parent 04712535
......@@ -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'));
}
});
......
......@@ -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!');
}
}
......
......@@ -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;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!