'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=', 'setTyping' => 'https://api.weixin.qq.com/cgi-bin/message/custom/typing?access_token=', 'uploadTempMedia' => 'https://api.weixin.qq.com/cgi-bin/media/upload?access_token=' ]; public function __call($method, $arguments) { if (!isset($this->requestUrl[$method])) { throw new ErrorException('Method ' . $method . ' not exists'); } $num = count($arguments); if ($num != 2) { throw new ErrorException('Method ' . $method . ' needs two arguments. ' . $num . ' arguments given.'); } $url = $this->requestUrl[$method] . $arguments[0]; $data = $this->curl($url, json_encode($arguments[1], JSON_UNESCAPED_UNICODE)); return $data; } public function uploadTempMedia($token, $data) { $url = $this->requestUrl['uploadTempMedia'] . $token.'&type=image'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_SAFE_UPLOAD, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_HEADER, false); $data = curl_exec($curl); curl_close($curl); return $data; } }