Files
kiri-wchat/officialaccount/AfficialAccount.php
T
as2252258@163.com 7f138ef255 add clear
2019-11-11 18:14:47 +08:00

37 lines
783 B
PHP

<?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();
}
}