/**
  * 通过授权获取用户.
  *
  * @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();
 }
Exemple #2
0
 /**
  * 魔术调用
  *
  * @param string $method
  * @param array  $args
  *
  * @return mixed
  */
 public function __call($method, $args)
 {
     if (in_array($method, $this->events, true)) {
         $callback = array_shift($args);
         is_callable($callback) && $this->listeners->set($method, $callback);
         return;
     }
 }
Exemple #3
0
 /**
  * 处理微信的请求
  *
  * @return mixed
  */
 protected function handleRequest()
 {
     if ($this->input->has('MsgId')) {
         return $this->handleMessage($this->input);
     } else {
         if ($this->input->has('MsgType') && $this->input('MsgType') == 'event') {
             return $this->handleEvent($this->input);
         }
     }
     return false;
 }
Exemple #4
0
 /**
  * 图片素材总数
  *
  * @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;
 }
Exemple #5
0
 /**
  * constructor
  */
 public function __construct()
 {
     parent::__construct(array_merge($_GET, $_POST));
 }