/** * 通过授权获取用户. * * @param string $to * @param string $state * @param string $scope * * @return Bag | null */ public function authorize($to = null, $scope = 'snsapi_userinfo', $state = 'STATE') { if (!$this->input->get('state') && !$this->input->get('code')) { $this->redirect($to, $scope, $state); } return $this->user(); }
/** * 处理微信的请求 * * @return mixed */ protected function handleRequest() { $this->call('received', array($this->input)); if ($this->input->get('MsgType') && $this->input->get('MsgType') === 'event') { return $this->handleEvent($this->input); } elseif ($this->input->get('MsgId')) { return $this->handleMessage($this->input); } return false; }
/** * 图片素材总数. * * @param string $type * * @return array|int */ public function stats($type = null) { $response = $this->http->get(self::API_FOREVER_COUNT); $response['voice'] = $response['voice_count']; $response['image'] = $response['image_count']; $response['video'] = $response['video_count']; $response['news'] = $response['news_count']; $response = new Bag($response); return $type ? $response->get($type) : $response; }