add clear

This commit is contained in:
2020-09-10 17:08:50 +08:00
parent bf18dd5951
commit 0d202fce14
+14 -8
View File
@@ -4,10 +4,16 @@
namespace wchat\officialaccount; namespace wchat\officialaccount;
use Exception;
use wchat\common\Result;
use wchat\officialaccount\dcaler\SnsInfo; use wchat\officialaccount\dcaler\SnsInfo;
use wchat\common\HttpClient; use wchat\common\HttpClient;
use wchat\officialaccount\dcaler\Authorization as DAuth; use wchat\officialaccount\dcaler\Authorization as DAuth;
/**
* Class Authorization
* @package wchat\officialaccount
*/
class Authorization extends AfficialAccount class Authorization extends AfficialAccount
{ {
@@ -21,14 +27,14 @@ class Authorization extends AfficialAccount
/** /**
* @param $code * @param $code
* @return array|mixed|\wchat\Result * @return array|mixed|Result
* @throws \Exception * @throws Exception
*/ */
public function authorization_user_info($code) public function authorization_user_info($code)
{ {
$param = $this->GetAccessTokenByCode($code); $param = $this->GetAccessTokenByCode($code);
if (!$param->isResultsOK()) { if (!$param->isResultsOK()) {
throw new \Exception($param->getMessage()); throw new Exception($param->getMessage());
} }
$requestParam['access_token'] = $param->getData('access_token'); $requestParam['access_token'] = $param->getData('access_token');
@@ -49,7 +55,7 @@ class Authorization extends AfficialAccount
/** /**
* @param $code * @param $code
* @return array|mixed|\wchat\Result * @return array|mixed|Result
*/ */
private function GetAccessTokenByCode($code) private function GetAccessTokenByCode($code)
{ {
@@ -65,7 +71,7 @@ class Authorization extends AfficialAccount
/** /**
* @param $openid * @param $openid
* @return DAuth * @return DAuth
* @throws \Exception * @throws Exception
* 获取用户信息 * 获取用户信息
*/ */
public function To_grant_authorization($openid) public function To_grant_authorization($openid)
@@ -76,7 +82,7 @@ class Authorization extends AfficialAccount
$authorization = $this->request->get($this->url, $requestParam); $authorization = $this->request->get($this->url, $requestParam);
if (!$authorization) { if (!$authorization) {
throw new \Exception($authorization->getMessage()); throw new Exception($authorization->getMessage());
} }
return DAuth::instance($authorization->getData()); return DAuth::instance($authorization->getData());
@@ -86,7 +92,7 @@ class Authorization extends AfficialAccount
/** /**
* @param $long_url * @param $long_url
* @return string * @return string
* @throws \Exception * @throws Exception
*/ */
public function Turn_to_short_chain($long_url) public function Turn_to_short_chain($long_url)
{ {
@@ -96,7 +102,7 @@ class Authorization extends AfficialAccount
$result = $this->request->post($this->turn . $token, $requestParam); $result = $this->request->post($this->turn . $token, $requestParam);
if (!$result->isResultsOK()) { if (!$result->isResultsOK()) {
throw new \Exception($result->getMessage()); throw new Exception($result->getMessage());
} }
return $result->getData('short_url'); return $result->getData('short_url');
} }