savePath = $path; } /** * @param $path * @param $width * @return array|mixed|Result * @throws \Exception */ public function createwxaqrcode($path, $width) { $url = $this->wxaqr . $this->getAccessToken(); $sendBody['path'] = $path; $sendBody['width'] = $width; $this->request->setMethod(HttpClient::POST); $this->request->setCallback([$this, 'saveByPath']); return $this->request->post($url, $sendBody); } /** * @param $path * @param $width * @param bool $is_hyaline * @param bool $auto_color * @param string $line_color * @return array|mixed|Result * @throws \Exception */ public function getwxacode($path, $width, $is_hyaline = false, $auto_color = false, $line_color = '') { $sendBody['path'] = $path; $sendBody['width'] = $width; $sendBody['auto_color'] = $auto_color; $sendBody['is_hyaline'] = $is_hyaline; if ($auto_color) { $sendBody['line_color'] = $line_color; } $url = $this->getwxacode . $this->getAccessToken(); $this->request->setMethod(HttpClient::POST); $this->request->setCallback([$this, 'saveByPath']); return $this->request->post($url, $sendBody); } /** * @param $path * @param $width * @param bool $is_hyaline * @param bool $auto_color * @param string $line_color * @return array|mixed|Result * @throws \Exception */ public function getwxacodeunlimit($path, $width, $is_hyaline = false, $auto_color = false, $line_color = '') { $sendBody['path'] = $path; $sendBody['width'] = $width; $sendBody['auto_color'] = $auto_color; $sendBody['is_hyaline'] = $is_hyaline; if ($auto_color) { $sendBody['line_color'] = $line_color; } $url = $this->getwxacodeunlimit . $this->getAccessToken(); $this->request->setMethod(HttpClient::POST); $this->request->setCallback([$this, 'saveByPath']); return $this->request->post($url, $sendBody); } /** * @param mixed $body * @return string * @throws \Exception */ public function saveByPath($body) { if (!is_null($json = json_decode($body))) { throw new \Exception($json['errmsg'], $json['errcode']); } $push = md5_file($body) . '.png'; file_put_contents($this->savePath . $push, $this->savePath); return $this->savePath . $push; } }