add clear
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace officialaccount;
|
||||
|
||||
|
||||
use common\HttpClient;
|
||||
use common\Miniprogarampage;
|
||||
|
||||
abstract class AfficialAccount extends Miniprogarampage
|
||||
{
|
||||
protected static $instance;
|
||||
|
||||
private $url = 'https://api.weixin.qq.com/cgi-bin/token?';
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
* @throws
|
||||
*/
|
||||
public function generateAccess_token()
|
||||
{
|
||||
if (!empty($this->config->getToken())) {
|
||||
return $this->config->getToken();
|
||||
}
|
||||
$requestParam['grant_type'] = 'client_credential';
|
||||
$requestParam['appid'] = $this->config->getAppid();
|
||||
$requestParam['secret'] = $this->config->getAppsecret();
|
||||
|
||||
$result = HttpClient::NewRequest()->get($this->url, $requestParam);
|
||||
if (!$result->isResultsOK()) {
|
||||
throw new \Exception($result->getMessage(), $result->getCode());
|
||||
}
|
||||
return $result->getData();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user