add clear
This commit is contained in:
@@ -4,41 +4,8 @@
|
||||
namespace wchat\wx;
|
||||
|
||||
|
||||
use wchat\common\Miniprogarampage;
|
||||
use wchat\common\Multiprogramming;
|
||||
|
||||
class SmallProgram extends Miniprogarampage
|
||||
class SmallProgram extends Multiprogramming
|
||||
{
|
||||
|
||||
protected static $instance;
|
||||
|
||||
private $url = 'https://api.weixin.qq.com/cgi-bin/token';
|
||||
|
||||
|
||||
/**
|
||||
* @param bool $get_token
|
||||
* @return mixed
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function generateAccess_token($get_token = false)
|
||||
{
|
||||
if (!empty($this->config->getToken())) {
|
||||
return $this->config->getToken();
|
||||
}
|
||||
$query = [
|
||||
'grant_type' => 'client_credential',
|
||||
'appid' => $this->config->getAppid(),
|
||||
'secret' => $this->config->getAppsecret()
|
||||
];
|
||||
$this->request->setErrorField('errcode');
|
||||
$this->request->setErrorMsgField('errmsg');
|
||||
$param = $this->request->get($this->url, $query);
|
||||
if (!$param->isResultsOK()) {
|
||||
throw new \Exception($param->getMessage());
|
||||
}
|
||||
if ($get_token) {
|
||||
return $param->getData('access_token');
|
||||
}
|
||||
return $param->getData();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user