/** * 图片素材总数. * * @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; }
/** * 获取jsticket. * * @return string */ public function getTicket() { $key = 'overtrue.wechat.jsapi_ticket.' . $this->appId; // for php 5.3 $appId = $this->appId; $appSecret = $this->appSecret; $cache = $this->cache; $apiTicket = self::API_TICKET; return $this->cache->get($key, function ($key) use($appId, $appSecret, $cache, $apiTicket) { $http = new Http(new AccessToken($appId, $appSecret)); $result = $http->get($apiTicket); $cache->set($key, $result['ticket'], $result['expires_in']); return $result['ticket']; }); }
/** * 获取菜单【查询接口,能获取到任意方式设置的菜单】. * * @return array */ public function current() { $menus = $this->http->get(self::API_QUERY); return empty($menus) ? array() : $menus; }
/** * 获取所有在线的. * * @return array */ public function onlines() { $response = $this->http->get(self::API_ONLINE); return $response['kf_online_list']; }
/** * 获取用户列表. * * @param string $nextOpenId * * @return Bag */ public function lists($nextOpenId = null) { $params = array('next_openid' => $nextOpenId); return new Bag($this->http->get(self::API_LIST, $params)); }
/** * 获取access token. * * @param string $code * * @return string */ public function getAccessPermission($code) { $params = array('appid' => $this->appId, 'secret' => $this->appSecret, 'code' => $code, 'grant_type' => 'authorization_code'); return $this->lastPermission = $this->http->get(self::API_TOKEN_GET, $params); }