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

39 lines
695 B
PHP

<?php
namespace wchat;
use common\Miniprogarampage;
class SmallProgram extends Miniprogarampage
{
protected static $instance;
private $url = 'https://api.weixin.qq.com/cgi-bin/token';
/**
* @return mixed
* @throws \Exception
*/
public function generateAccess_token()
{
if (!empty($this->config->getToken())) {
return $this->config->getToken();
}
$query = [
'grant_type' => 'client_credential',
'appid' => $this->config->getAppid(),
'secret' => $this->config->getAppsecret()
];
$param = $this->request->get($this->url, $query);
if (!$param->isResultsOK()) {
throw new \Exception($param->getMessage());
}
return $param->getData();
}
}