diff --git a/addons/syslogin/service/Application.php b/addons/syslogin/service/Application.php index d48cb282..8b4aff00 100644 --- a/addons/syslogin/service/Application.php +++ b/addons/syslogin/service/Application.php @@ -15,9 +15,9 @@ class Application { * @var array */ private $providers = [ - 'qq' => 'Qq', - 'weibo' => 'Weibo', - 'wechat' => 'Wechat', + 'qq' => 'Qq', + 'weibo' => 'Weibo', + 'wechat' => 'Wechat', ]; /** @@ -26,15 +26,14 @@ class Application { */ protected $services = []; - public function __construct($options = []) - { + public function __construct($options = []) { $options = array_intersect_key($options, $this->providers); $options = array_merge($this->config, is_array($options) ? $options : []); foreach ($options as $key => &$option) { $option['app_id'] = isset($option['app_id']) ? $option['app_id'] : ''; $option['app_secret'] = isset($option['app_secret']) ? $option['app_secret'] : ''; // 如果未定义回调地址则自动生成 - $option['callback'] = isset($option['callback']) && $option['callback'] ? $option['callback'] : addon_url('syslogin/index/callback', [':platform' => $key], false, true); + $option['callback'] = isset($option['callback']) && $option['callback'] ? $option['callback'] : addons_url('syslogin/index/callback', [':platform' => $key], false, true); } $this->config = $options; //注册服务器提供者 @@ -44,8 +43,7 @@ class Application { /** * 注册服务提供者 */ - private function registerProviders() - { + private function registerProviders() { foreach ($this->providers as $k => $v) { $this->services[$k] = function () use ($k, $v) { $options = $this->config[$k]; @@ -55,13 +53,11 @@ class Application { } } - public function __set($key, $value) - { + public function __set($key, $value) { $this->services[$key] = $value; } - public function __get($key) - { + public function __get($key) { return isset($this->services[$key]) ? $this->services[$key]($this) : null; } } diff --git a/addons/syslogin/service/Qq.php b/addons/syslogin/service/Qq.php index 30d77e7f..cfaeaeac 100644 --- a/addons/syslogin/service/Qq.php +++ b/addons/syslogin/service/Qq.php @@ -72,7 +72,8 @@ class Qq { "oauth_consumer_key" => $this->config['app_id'], "openid" => $openid, ]; - $ret = Http::get(self::GET_USERINFO_URL, $queryarr); + $client = new \GuzzleHttp\Client(); + $ret = $client->post(self::GET_USERINFO_URL, ['form_params' => $queryarr])->getBody()->getContents(); $userinfo = (array) json_decode($ret, true); if (!$userinfo || !isset($userinfo['ret']) || $userinfo['ret'] !== 0) { return []; @@ -108,7 +109,8 @@ class Qq { "redirect_uri" => $this->config['callback'], "code" => $code, ); - $ret = Http::get(self::GET_ACCESS_TOKEN_URL, $queryarr); + $client = new \GuzzleHttp\Client(); + $ret = $client->post(self::GET_ACCESS_TOKEN_URL, ['form_params' => $queryarr])->getBody()->getContents(); $params = []; parse_str($ret, $params); return $params ? $params : []; @@ -120,7 +122,8 @@ class Qq { * @return string */ private function getOpenId($access_token = '') { - $response = Http::get(self::GET_OPENID_URL, ['access_token' => $access_token]); + $client = new \GuzzleHttp\Client(); + $response = $client->post(self::GET_OPENID_URL, ['form_params' => ['access_token' => $access_token]])->getBody()->getContents(); if (strpos($response, "callback") !== false) { $lpos = strpos($response, "("); $rpos = strrpos($response, ")"); diff --git a/addons/syslogin/service/Weibo.php b/addons/syslogin/service/Weibo.php index b38a8312..60170937 100644 --- a/addons/syslogin/service/Weibo.php +++ b/addons/syslogin/service/Weibo.php @@ -70,7 +70,8 @@ class Weibo { "access_token" => $access_token, "uid" => $uid, ]; - $ret = Http::get(self::GET_USERINFO_URL, $queryarr); + $client = new \GuzzleHttp\Client(); + $ret = $client->post(self::GET_USERINFO_URL, ['form_params' => $queryarr])->getBody()->getContents(); $userinfo = (array) json_decode($ret, true); if (!$userinfo || isset($userinfo['error_code'])) { return []; @@ -107,7 +108,8 @@ class Weibo { "redirect_uri" => $this->config['callback'], "code" => $code, ); - $response = Http::post(self::GET_ACCESS_TOKEN_URL, $queryarr); + $client = new \GuzzleHttp\Client(); + $response = $client->post(self::GET_ACCESS_TOKEN_URL, ['form_params' => $queryarr])->getBody()->getContents(); $ret = (array) json_decode($response, true); return $ret ? $ret : []; } diff --git a/addons/syslogin/view/login.html b/addons/syslogin/view/login.html index 29f8c459..eafc9fff 100644 --- a/addons/syslogin/view/login.html +++ b/addons/syslogin/view/login.html @@ -1,9 +1,5 @@ - - \ No newline at end of file +
+ QQ登录 + 微信登录 + 微博登录 +
\ No newline at end of file diff --git a/runtime/sql/install.sql b/runtime/sql/install.sql index a520c02f..585e70b4 100644 --- a/runtime/sql/install.sql +++ b/runtime/sql/install.sql @@ -462,7 +462,7 @@ CREATE TABLE `sent_member` ( `reg_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '注册时间', `last_login_ip` bigint(20) NOT NULL DEFAULT '0' COMMENT '最后登录IP', `last_login_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最后登录时间', - `status` tinyint(4) NOT NULL DEFAULT '0' COMMENT '会员状态', + `status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '会员状态', PRIMARY KEY (`uid`), KEY `status` (`status`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='会员表';