diff --git a/Library/Think/Oauth/Driver.php b/Library/Think/Oauth/Driver.php index fd9948f7..cfb8938f 100644 --- a/Library/Think/Oauth/Driver.php +++ b/Library/Think/Oauth/Driver.php @@ -77,16 +77,16 @@ abstract class Driver { * @param array $config */ public function __construct($config = []){ - $this->appKey = $config['app_key']; - $this->appSecret = $config['app_secret']; - $this->authorize = isset($config['authorize'])?$config['authorize']:''; - $this->callback = isset($config['callback'])?$config['callback']:''; + $this->appKey = $config['app_key']; + $this->appSecret = $config['app_secret']; + $this->authorize = isset($config['authorize']) ? $config['authorize'] : ''; + $this->callback = isset($config['callback']) ? $config['callback'] : ''; } // 跳转到授权登录页面 - public function login($callback=''){ + public function login($callback = ''){ if($callback) { - $this->callback = $callback; + $this->callback = $callback; } //跳转到授权页面 header('Location: ' . $this->getRequestCodeURL()); @@ -110,7 +110,7 @@ abstract class Driver { if(is_array($_param)){ $params = array_merge($params, $_param); } else { - throw new Exception('AUTHORIZE配置不正确!'); + throw new \Exception('AUTHORIZE配置不正确!'); } } return $this->getRequestCodeURL . '?' . http_build_query($params); @@ -194,7 +194,7 @@ abstract class Driver { $opts[CURLOPT_POSTFIELDS] = $params; break; default: - throw new Exception('不支持的请求方式!'); + throw new \Exception('不支持的请求方式!'); } /* 初始化并执行curl请求 */ @@ -203,7 +203,7 @@ abstract class Driver { $data = curl_exec($ch); $error = curl_error($ch); curl_close($ch); - if($error) throw new Exception('请求发生错误:' . $error); + if($error) throw new \Exception('请求发生错误:' . $error); return $data; } diff --git a/Library/Think/Oauth/Driver/Baidu.php b/Library/Think/Oauth/Driver/Baidu.php index e4951636..0555af54 100644 --- a/Library/Think/Oauth/Driver/Baidu.php +++ b/Library/Think/Oauth/Driver/Baidu.php @@ -58,7 +58,7 @@ class Baidu extends Driver{ $data['openid'] = $this->openid(); return $data; } else - throw new Exception("获取百度ACCESS_TOKEN出错:{$data['error']}"); + throw new \Exception("获取百度ACCESS_TOKEN出错:{$data['error']}"); } /** @@ -86,7 +86,7 @@ class Baidu extends Driver{ $userInfo['avatar'] = "http://tb.himg.baidu.com/sys/portrait/item/{$data['portrait']}"; return $userInfo; } else { - throw new Exception("获取百度用户信息失败:{$data['error_msg']}"); + throw new \Exception("获取百度用户信息失败:{$data['error_msg']}"); } } diff --git a/Library/Think/Oauth/Driver/Diandian.php b/Library/Think/Oauth/Driver/Diandian.php index f949f76d..ecb467dc 100644 --- a/Library/Think/Oauth/Driver/Diandian.php +++ b/Library/Think/Oauth/Driver/Diandian.php @@ -59,7 +59,7 @@ class Diandian extends Driver{ unset($data['uid']); return $data; } else - throw new Exception("获取点点网ACCESS_TOKEN出错:{$data['error']}"); + throw new \Exception("获取点点网ACCESS_TOKEN出错:{$data['error']}"); } /** diff --git a/Library/Think/Oauth/Driver/Douban.php b/Library/Think/Oauth/Driver/Douban.php index a41e8f95..47bb663c 100644 --- a/Library/Think/Oauth/Driver/Douban.php +++ b/Library/Think/Oauth/Driver/Douban.php @@ -57,7 +57,7 @@ class Douban extends Driver{ unset($data['douban_user_id']); return $data; } else - throw new Exception("获取豆瓣ACCESS_TOKEN出错:{$data['msg']}"); + throw new \Exception("获取豆瓣ACCESS_TOKEN出错:{$data['msg']}"); } /** diff --git a/Library/Think/Oauth/Driver/Github.php b/Library/Think/Oauth/Driver/Github.php index 0c142acb..55d06342 100644 --- a/Library/Think/Oauth/Driver/Github.php +++ b/Library/Think/Oauth/Driver/Github.php @@ -57,7 +57,7 @@ class Github extends Driver{ $data['openid'] = $this->getOpenId(); return $data; } else - throw new Exception("获取 Github ACCESS_TOKEN出错:未知错误"); + throw new \Exception("获取 Github ACCESS_TOKEN出错:未知错误"); } /** diff --git a/Library/Think/Oauth/Driver/Google.php b/Library/Think/Oauth/Driver/Google.php index a0cbe5d3..23ac7edb 100644 --- a/Library/Think/Oauth/Driver/Google.php +++ b/Library/Think/Oauth/Driver/Google.php @@ -63,7 +63,7 @@ class Google extends Driver{ $data['openid'] = $this->getOpenId(); return $data; } else - throw new Exception("获取 Google ACCESS_TOKEN出错:未知错误"); + throw new \Exception("获取 Google ACCESS_TOKEN出错:未知错误"); } /** diff --git a/Library/Think/Oauth/Driver/Kaixin.php b/Library/Think/Oauth/Driver/Kaixin.php index c51a1aa8..7b140bfa 100644 --- a/Library/Think/Oauth/Driver/Kaixin.php +++ b/Library/Think/Oauth/Driver/Kaixin.php @@ -58,7 +58,7 @@ class Kaixin extends Driver{ $data['openid'] = $this->getOpenId(); return $data; } else - throw new Exception("获取开心网ACCESS_TOKEN出错:{$data['error']}"); + throw new \Exception("获取开心网ACCESS_TOKEN出错:{$data['error']}"); } /** diff --git a/Library/Think/Oauth/Driver/Msn.php b/Library/Think/Oauth/Driver/Msn.php index 84db515f..18b49ff0 100644 --- a/Library/Think/Oauth/Driver/Msn.php +++ b/Library/Think/Oauth/Driver/Msn.php @@ -64,7 +64,7 @@ class Msn extends Driver{ $data['openid'] = $this->getOpenId(); return $data; } else - throw new Exception("获取 MSN ACCESS_TOKEN出错:未知错误"); + throw new \Exception("获取 MSN ACCESS_TOKEN出错:未知错误"); } /** diff --git a/Library/Think/Oauth/Driver/Qq.php b/Library/Think/Oauth/Driver/Qq.php index cd682f35..57eab290 100644 --- a/Library/Think/Oauth/Driver/Qq.php +++ b/Library/Think/Oauth/Driver/Qq.php @@ -67,7 +67,7 @@ class Qq extends Driver{ $data['openid'] = $this->getOpenId(); return $data; } else - throw new Exception("获取腾讯QQ ACCESS_TOKEN 出错:{$result}"); + throw new \Exception("获取腾讯QQ ACCESS_TOKEN 出错:{$result}"); } /** diff --git a/Library/Think/Oauth/Driver/Renren.php b/Library/Think/Oauth/Driver/Renren.php index 5d0776c3..0981f142 100644 --- a/Library/Think/Oauth/Driver/Renren.php +++ b/Library/Think/Oauth/Driver/Renren.php @@ -83,7 +83,7 @@ class Renren extends Driver{ unset($data['user']); return $data; } else - throw new Exception("获取人人网ACCESS_TOKEN出错:{$data['error_description']}"); + throw new \Exception("获取人人网ACCESS_TOKEN出错:{$data['error_description']}"); } /** diff --git a/Library/Think/Oauth/Driver/Sina.php b/Library/Think/Oauth/Driver/Sina.php index 2e0404e7..0f52615c 100644 --- a/Library/Think/Oauth/Driver/Sina.php +++ b/Library/Think/Oauth/Driver/Sina.php @@ -38,13 +38,13 @@ class Sina extends Driver{ * @param string $method HTTP请求方法 默认为GET * @return json */ - public function call($api, $param = '', $method = 'GET'){ + public function call($api, $param = '', $method = 'GET', $multi = false){ /* 新浪微博调用公共参数 */ $params = array( 'access_token' => $this->token['access_token'], ); - $data = $this->http($this->url($api, '.json'), $this->param($params, $param), $method); + $data = $this->http($this->url($api, '.json'), $this->param($params, $param), $method, $multi); return json_decode($data, true); } @@ -59,7 +59,7 @@ class Sina extends Driver{ unset($data['uid']); return $data; } else - throw new Exception("获取新浪微博ACCESS_TOKEN出错:{$data['error']}"); + throw new \Exception("获取新浪微博ACCESS_TOKEN出错:{$data['error']}"); } /** diff --git a/Library/Think/Oauth/Driver/Sohu.php b/Library/Think/Oauth/Driver/Sohu.php index f1ffe9eb..bdf8eb37 100644 --- a/Library/Think/Oauth/Driver/Sohu.php +++ b/Library/Think/Oauth/Driver/Sohu.php @@ -59,7 +59,7 @@ class Sohu extends Driver{ unset($data['open_id']); return $data; } else - throw new Exception("获取搜狐ACCESS_TOKEN出错:{$data['error']}"); + throw new \Exception("获取搜狐ACCESS_TOKEN出错:{$data['error']}"); } /** diff --git a/Library/Think/Oauth/Driver/T163.php b/Library/Think/Oauth/Driver/T163.php index a7aee279..f2703fc8 100644 --- a/Library/Think/Oauth/Driver/T163.php +++ b/Library/Think/Oauth/Driver/T163.php @@ -59,7 +59,7 @@ class T163 extends Driver{ unset($data['uid']); return $data; } else - throw new Exception("获取网易微博ACCESS_TOKEN出错:{$data['error']}"); + throw new \Exception("获取网易微博ACCESS_TOKEN出错:{$data['error']}"); } /** diff --git a/Library/Think/Oauth/Driver/Taobao.php b/Library/Think/Oauth/Driver/Taobao.php index c9aa8266..2525868f 100644 --- a/Library/Think/Oauth/Driver/Taobao.php +++ b/Library/Think/Oauth/Driver/Taobao.php @@ -61,7 +61,7 @@ class Taobao extends Driver{ unset($data['taobao_user_id']); return $data; } else - throw new Exception("获取淘宝网ACCESS_TOKEN出错:{$data['error']}"); + throw new \Exception("获取淘宝网ACCESS_TOKEN出错:{$data['error']}"); } /** diff --git a/Library/Think/Oauth/Driver/Tencent.php b/Library/Think/Oauth/Driver/Tencent.php index 258d37d5..3ad40c5d 100644 --- a/Library/Think/Oauth/Driver/Tencent.php +++ b/Library/Think/Oauth/Driver/Tencent.php @@ -38,7 +38,7 @@ class Tencent extends Driver{ * @param string $method HTTP请求方法 默认为GET * @return json */ - public function call($api, $param = '', $method = 'GET'){ + public function call($api, $param = '', $method = 'GET', $multi = false){ /* 腾讯微博调用公共参数 */ $params = array( 'oauth_consumer_key' => $this->AppKey, @@ -50,7 +50,7 @@ class Tencent extends Driver{ 'format' => 'json' ); - $data = $this->http($this->url($api), $this->param($params, $param), $method); + $data = $this->http($this->url($api), $this->param($params, $param), $method, $multi); return json_decode($data, true); } @@ -64,7 +64,7 @@ class Tencent extends Driver{ if($data['access_token'] && $data['expires_in'] && $data['openid']) return $data; else - throw new Exception("获取腾讯微博 ACCESS_TOKEN 出错:{$result}"); + throw new \Exception("获取腾讯微博 ACCESS_TOKEN 出错:{$result}"); } /** diff --git a/Library/Think/Oauth/Driver/X360.php b/Library/Think/Oauth/Driver/X360.php index 38f2d30a..7058e45f 100644 --- a/Library/Think/Oauth/Driver/X360.php +++ b/Library/Think/Oauth/Driver/X360.php @@ -58,7 +58,7 @@ class X360 extends Driver{ $data['openid'] = $this->getOpenId(); return $data; } else - throw new Exception("获取360开放平台ACCESS_TOKEN出错:{$data['error']}"); + throw new \Exception("获取360开放平台ACCESS_TOKEN出错:{$data['error']}"); } /**