From 60d10291341c6f41c8be78d1bb99aafbc8feaca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=80=99=E5=AD=A6=E6=9D=B0?= Date: Tue, 15 May 2018 11:59:57 +0800 Subject: [PATCH] add groups api --- src/PdAuth/OAuth.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/PdAuth/OAuth.php b/src/PdAuth/OAuth.php index 536292a..f36fd3f 100644 --- a/src/PdAuth/OAuth.php +++ b/src/PdAuth/OAuth.php @@ -2,6 +2,8 @@ namespace PdAuth; +use PdAuth\Middleware\Authenticate; + class OAuth { @@ -38,24 +40,31 @@ class OAuth /** * 根据用户token获取用户信息 - * @param $username * @param $token - * @return array|null + * @return null */ public function getUserInfo($token) { $token = urlencode($token); - $resp = $this->get("$this->host/api/user_info?access_token=$token"); + $resp = $this->get("$this->host/api/user/info?access_token=$token"); if ($resp['code'] == 0) { return $resp['data']; } return null; } - public function getGroups($token) + /** + * 获取用户组 + * @param null $token + * @return null + */ + public function getGroupUsers($token = null) { + if ($token == null) { + $token = $_COOKIE[Authenticate::CookieName]; + } $token = urlencode($token); - $resp = $this->get("$this->host/api/{$this->id}/groups?access_token=$token"); + $resp = $this->get("$this->host/api/group/users?access_token=$token"); if ($resp['code'] == 0) { return $resp['data']; }