This commit is contained in:
候学杰 2019-02-21 12:05:41 +08:00
parent 9caf26e7cd
commit 48a7d08bac

View File

@ -48,9 +48,21 @@ class Base
return $request; return $request;
} }
public function transformForAccessTokenRequest($uri, $params)
{
$uri = new Uri($uri);
foreach ($params as $param) {
$uri = Uri::withQueryValues($uri, $params);
}
$request = new Request('GET', $uri, []);
return $request;
}
public function transformForGetRequest($uri, $params) public function transformForGetRequest($uri, $params)
{ {
$uri = new Uri($uri); $uri = new Uri($uri);
$uri = Uri::withQueryValue($uri, 'access_token', $this->getAccessToken());
foreach ($params as $param) { foreach ($params as $param) {
$uri = Uri::withQueryValues($uri, $params); $uri = Uri::withQueryValues($uri, $params);
} }
@ -81,7 +93,7 @@ class Base
return $token; return $token;
} }
$request = $this->transformForGetRequest('gettoken', [ $request = $this->transformForAccessTokenRequest('gettoken', [
'corpid' => $config['corp_id'], 'corpid' => $config['corp_id'],
'corpsecret' => $config['secret'] 'corpsecret' => $config['secret']
]); ]);