2019-10-25 15:20:09 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace wchat;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Token extends Miniprogarampage
|
|
|
|
|
{
|
|
|
|
|
|
2019-11-04 14:46:37 +08:00
|
|
|
private $url = 'https://api.weixin.qq.com/cgi-bin/token';
|
2019-10-25 15:20:09 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return mixed|null
|
|
|
|
|
*/
|
|
|
|
|
public function generateAccess_token()
|
|
|
|
|
{
|
|
|
|
|
$query = [
|
|
|
|
|
'grant_type' => 'client_credential',
|
|
|
|
|
'appid' => $this->config->getAppid(),
|
|
|
|
|
'secret' => $this->config->getAppsecret()
|
|
|
|
|
];
|
|
|
|
|
$param = $this->request->get($this->url, $query);
|
|
|
|
|
if (!$param->isResultsOK()) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return $param->getData('access_token');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|