Beispiel #1
0
 /**
  * 通过授权获取用户.
  *
  * @param string $to
  * @param string $state
  * @param string $scope
  *
  * @return Collection | null
  */
 public function authorize($to = null, $scope = 'snsapi_userinfo', $state = 'STATE')
 {
     if (!$this->input->has('state') && !$this->input->has('code')) {
         $this->redirect($to, $scope, $state);
     }
     return $this->user();
 }
Beispiel #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;
     }
 }
Beispiel #3
0
 /**
  * Handle request.
  *
  * @return mixed
  */
 protected function handleRequest()
 {
     if ($this->input->has('MsgType') && $this->input->get('MsgType') === 'event') {
         return $this->handleEvent($this->input);
     } elseif ($this->input->has('MsgId')) {
         return $this->handleMessage($this->input);
     }
     return self::EMPTY_STRING;
 }
Beispiel #4
0
 /**
  * Handle request.
  *
  * @return mixed
  */
 protected function handleRequest()
 {
     $response = null;
     if ($this->input->has('MsgType') && $this->input->get('MsgType') === 'event') {
         $response = $this->handleEvent($this->input);
     } elseif ($this->input->has('MsgId')) {
         $response = $this->handleMessage($this->input);
     }
     return $response;
 }
Beispiel #5
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 Collection($response);
     return $type ? $response->get($type) : $response;
 }
Beispiel #6
0
 /**
  * constructor
  */
 public function __construct()
 {
     parent::__construct(array_merge($_GET, $_POST));
 }
Beispiel #7
0
 /**
  * Handle message.
  *
  * @param array $message
  *
  * @return mixed
  */
 protected function handleMessage($message)
 {
     $handler = $this->messageHandler;
     if (!is_callable($handler)) {
         Log::debug('No handler enabled.');
         return;
     }
     Log::debug('Message detail:', $message);
     $message = new Collection($message);
     $type = $this->messageTypeMapping[$message->get('MsgType')];
     $response = null;
     if ($this->messageFilter & $type) {
         $response = call_user_func_array($handler, [$message]);
     }
     return $response;
 }
Beispiel #8
0
 /**
  * Return all items.
  *
  * @return array
  *
  * @throws InvalidArgumentException
  */
 public function all()
 {
     $this->checkRequiredAttributes();
     return parent::all();
 }
Beispiel #9
0
 /**
  * Handle message.
  *
  * @param array $message
  *
  * @return mixed
  */
 protected function handleMessage($message)
 {
     $message = new Collection($message);
     $response = $handler = null;
     if ($message->get('MsgType') && $message->get('MsgType') === 'event') {
         $handler = $this->eventListener;
     } elseif (!empty($message['MsgId'])) {
         $handler = $this->messageListener;
     }
     is_callable($handler) && ($response = call_user_func_array($handler, [$message]));
     return $response;
 }
Beispiel #10
0
 /**
  * Override parent get() method.
  *
  * @param string $attribute
  * @param mixed  $default
  */
 public function get($attribute, $default = null)
 {
     if ($alias = array_search($attribute, $this->aliases, true)) {
         $attribute = $alias;
     }
     return parent::get($attribute, $default);
 }
Beispiel #11
0
 /**
  * Constructor.
  *
  * @param array $attributes
  */
 public function __construct($attributes = [])
 {
     parent::__construct($attributes);
 }
Beispiel #12
0
 /**
  * Constructor.
  *
  * @param string  $token
  * @param Cryptor $cryptor
  */
 public function __construct($token, Cryptor $cryptor)
 {
     parent::__construct($this->build($cryptor));
     $this->validate($token);
 }
 /**
  * Handle message.
  *
  * @param array $message
  *
  * @return mixed
  */
 protected function handleMessage($message)
 {
     $handler = $this->messageHandler;
     $verifyHandler = $this->verifyHandler;
     if (!is_callable($handler)) {
         Log::debug('No handler enabled.');
         return;
     }
     Log::debug('Message detail:', $message);
     $message = new Collection($message);
     //处理verifyTicket
     if ($message->get('InfoType') == 'component_verify_ticket') {
         call_user_func_array($verifyHandler, [$message]);
     }
     $type = $this->messageTypeMapping[$message->get('InfoType')];
     $response = null;
     if ($this->messageFilter & $type) {
         $response = call_user_func_array($handler, [$message]);
     }
     return $response;
 }