mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 15:12:48 +08:00
Oauth接口驱动异常抛出添加命名空间
This commit is contained in:
@@ -77,16 +77,16 @@ abstract class Driver {
|
|||||||
* @param array $config
|
* @param array $config
|
||||||
*/
|
*/
|
||||||
public function __construct($config = []){
|
public function __construct($config = []){
|
||||||
$this->appKey = $config['app_key'];
|
$this->appKey = $config['app_key'];
|
||||||
$this->appSecret = $config['app_secret'];
|
$this->appSecret = $config['app_secret'];
|
||||||
$this->authorize = isset($config['authorize'])?$config['authorize']:'';
|
$this->authorize = isset($config['authorize']) ? $config['authorize'] : '';
|
||||||
$this->callback = isset($config['callback'])?$config['callback']:'';
|
$this->callback = isset($config['callback']) ? $config['callback'] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 跳转到授权登录页面
|
// 跳转到授权登录页面
|
||||||
public function login($callback=''){
|
public function login($callback = ''){
|
||||||
if($callback) {
|
if($callback) {
|
||||||
$this->callback = $callback;
|
$this->callback = $callback;
|
||||||
}
|
}
|
||||||
//跳转到授权页面
|
//跳转到授权页面
|
||||||
header('Location: ' . $this->getRequestCodeURL());
|
header('Location: ' . $this->getRequestCodeURL());
|
||||||
@@ -110,7 +110,7 @@ abstract class Driver {
|
|||||||
if(is_array($_param)){
|
if(is_array($_param)){
|
||||||
$params = array_merge($params, $_param);
|
$params = array_merge($params, $_param);
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('AUTHORIZE配置不正确!');
|
throw new \Exception('AUTHORIZE配置不正确!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->getRequestCodeURL . '?' . http_build_query($params);
|
return $this->getRequestCodeURL . '?' . http_build_query($params);
|
||||||
@@ -194,7 +194,7 @@ abstract class Driver {
|
|||||||
$opts[CURLOPT_POSTFIELDS] = $params;
|
$opts[CURLOPT_POSTFIELDS] = $params;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception('不支持的请求方式!');
|
throw new \Exception('不支持的请求方式!');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 初始化并执行curl请求 */
|
/* 初始化并执行curl请求 */
|
||||||
@@ -203,7 +203,7 @@ abstract class Driver {
|
|||||||
$data = curl_exec($ch);
|
$data = curl_exec($ch);
|
||||||
$error = curl_error($ch);
|
$error = curl_error($ch);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
if($error) throw new Exception('请求发生错误:' . $error);
|
if($error) throw new \Exception('请求发生错误:' . $error);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class Baidu extends Driver{
|
|||||||
$data['openid'] = $this->openid();
|
$data['openid'] = $this->openid();
|
||||||
return $data;
|
return $data;
|
||||||
} else
|
} 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']}";
|
$userInfo['avatar'] = "http://tb.himg.baidu.com/sys/portrait/item/{$data['portrait']}";
|
||||||
return $userInfo;
|
return $userInfo;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("获取百度用户信息失败:{$data['error_msg']}");
|
throw new \Exception("获取百度用户信息失败:{$data['error_msg']}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class Diandian extends Driver{
|
|||||||
unset($data['uid']);
|
unset($data['uid']);
|
||||||
return $data;
|
return $data;
|
||||||
} else
|
} else
|
||||||
throw new Exception("获取点点网ACCESS_TOKEN出错:{$data['error']}");
|
throw new \Exception("获取点点网ACCESS_TOKEN出错:{$data['error']}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class Douban extends Driver{
|
|||||||
unset($data['douban_user_id']);
|
unset($data['douban_user_id']);
|
||||||
return $data;
|
return $data;
|
||||||
} else
|
} else
|
||||||
throw new Exception("获取豆瓣ACCESS_TOKEN出错:{$data['msg']}");
|
throw new \Exception("获取豆瓣ACCESS_TOKEN出错:{$data['msg']}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class Github extends Driver{
|
|||||||
$data['openid'] = $this->getOpenId();
|
$data['openid'] = $this->getOpenId();
|
||||||
return $data;
|
return $data;
|
||||||
} else
|
} else
|
||||||
throw new Exception("获取 Github ACCESS_TOKEN出错:未知错误");
|
throw new \Exception("获取 Github ACCESS_TOKEN出错:未知错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class Google extends Driver{
|
|||||||
$data['openid'] = $this->getOpenId();
|
$data['openid'] = $this->getOpenId();
|
||||||
return $data;
|
return $data;
|
||||||
} else
|
} else
|
||||||
throw new Exception("获取 Google ACCESS_TOKEN出错:未知错误");
|
throw new \Exception("获取 Google ACCESS_TOKEN出错:未知错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class Kaixin extends Driver{
|
|||||||
$data['openid'] = $this->getOpenId();
|
$data['openid'] = $this->getOpenId();
|
||||||
return $data;
|
return $data;
|
||||||
} else
|
} else
|
||||||
throw new Exception("获取开心网ACCESS_TOKEN出错:{$data['error']}");
|
throw new \Exception("获取开心网ACCESS_TOKEN出错:{$data['error']}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class Msn extends Driver{
|
|||||||
$data['openid'] = $this->getOpenId();
|
$data['openid'] = $this->getOpenId();
|
||||||
return $data;
|
return $data;
|
||||||
} else
|
} else
|
||||||
throw new Exception("获取 MSN ACCESS_TOKEN出错:未知错误");
|
throw new \Exception("获取 MSN ACCESS_TOKEN出错:未知错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class Qq extends Driver{
|
|||||||
$data['openid'] = $this->getOpenId();
|
$data['openid'] = $this->getOpenId();
|
||||||
return $data;
|
return $data;
|
||||||
} else
|
} else
|
||||||
throw new Exception("获取腾讯QQ ACCESS_TOKEN 出错:{$result}");
|
throw new \Exception("获取腾讯QQ ACCESS_TOKEN 出错:{$result}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class Renren extends Driver{
|
|||||||
unset($data['user']);
|
unset($data['user']);
|
||||||
return $data;
|
return $data;
|
||||||
} else
|
} else
|
||||||
throw new Exception("获取人人网ACCESS_TOKEN出错:{$data['error_description']}");
|
throw new \Exception("获取人人网ACCESS_TOKEN出错:{$data['error_description']}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -38,13 +38,13 @@ class Sina extends Driver{
|
|||||||
* @param string $method HTTP请求方法 默认为GET
|
* @param string $method HTTP请求方法 默认为GET
|
||||||
* @return json
|
* @return json
|
||||||
*/
|
*/
|
||||||
public function call($api, $param = '', $method = 'GET'){
|
public function call($api, $param = '', $method = 'GET', $multi = false){
|
||||||
/* 新浪微博调用公共参数 */
|
/* 新浪微博调用公共参数 */
|
||||||
$params = array(
|
$params = array(
|
||||||
'access_token' => $this->token['access_token'],
|
'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);
|
return json_decode($data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ class Sina extends Driver{
|
|||||||
unset($data['uid']);
|
unset($data['uid']);
|
||||||
return $data;
|
return $data;
|
||||||
} else
|
} else
|
||||||
throw new Exception("获取新浪微博ACCESS_TOKEN出错:{$data['error']}");
|
throw new \Exception("获取新浪微博ACCESS_TOKEN出错:{$data['error']}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class Sohu extends Driver{
|
|||||||
unset($data['open_id']);
|
unset($data['open_id']);
|
||||||
return $data;
|
return $data;
|
||||||
} else
|
} else
|
||||||
throw new Exception("获取搜狐ACCESS_TOKEN出错:{$data['error']}");
|
throw new \Exception("获取搜狐ACCESS_TOKEN出错:{$data['error']}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class T163 extends Driver{
|
|||||||
unset($data['uid']);
|
unset($data['uid']);
|
||||||
return $data;
|
return $data;
|
||||||
} else
|
} else
|
||||||
throw new Exception("获取网易微博ACCESS_TOKEN出错:{$data['error']}");
|
throw new \Exception("获取网易微博ACCESS_TOKEN出错:{$data['error']}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class Taobao extends Driver{
|
|||||||
unset($data['taobao_user_id']);
|
unset($data['taobao_user_id']);
|
||||||
return $data;
|
return $data;
|
||||||
} else
|
} else
|
||||||
throw new Exception("获取淘宝网ACCESS_TOKEN出错:{$data['error']}");
|
throw new \Exception("获取淘宝网ACCESS_TOKEN出错:{$data['error']}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ class Tencent extends Driver{
|
|||||||
* @param string $method HTTP请求方法 默认为GET
|
* @param string $method HTTP请求方法 默认为GET
|
||||||
* @return json
|
* @return json
|
||||||
*/
|
*/
|
||||||
public function call($api, $param = '', $method = 'GET'){
|
public function call($api, $param = '', $method = 'GET', $multi = false){
|
||||||
/* 腾讯微博调用公共参数 */
|
/* 腾讯微博调用公共参数 */
|
||||||
$params = array(
|
$params = array(
|
||||||
'oauth_consumer_key' => $this->AppKey,
|
'oauth_consumer_key' => $this->AppKey,
|
||||||
@@ -50,7 +50,7 @@ class Tencent extends Driver{
|
|||||||
'format' => 'json'
|
'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);
|
return json_decode($data, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ class Tencent extends Driver{
|
|||||||
if($data['access_token'] && $data['expires_in'] && $data['openid'])
|
if($data['access_token'] && $data['expires_in'] && $data['openid'])
|
||||||
return $data;
|
return $data;
|
||||||
else
|
else
|
||||||
throw new Exception("获取腾讯微博 ACCESS_TOKEN 出错:{$result}");
|
throw new \Exception("获取腾讯微博 ACCESS_TOKEN 出错:{$result}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class X360 extends Driver{
|
|||||||
$data['openid'] = $this->getOpenId();
|
$data['openid'] = $this->getOpenId();
|
||||||
return $data;
|
return $data;
|
||||||
} else
|
} else
|
||||||
throw new Exception("获取360开放平台ACCESS_TOKEN出错:{$data['error']}");
|
throw new \Exception("获取360开放平台ACCESS_TOKEN出错:{$data['error']}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user