add clear
This commit is contained in:
@@ -18,7 +18,8 @@ $config->setAppsecret('');
|
|||||||
$config->setMchId('');
|
$config->setMchId('');
|
||||||
$config->setKey('');
|
$config->setKey('');
|
||||||
$config->setRemoteAddr('');
|
$config->setRemoteAddr('');
|
||||||
$config->
|
$config->setDeviceInfo('');
|
||||||
|
$config->setAccessToken('');
|
||||||
|
|
||||||
|
|
||||||
$instance = \wchat\Wx::getMiniProGaRamPage();
|
$instance = \wchat\Wx::getMiniProGaRamPage();
|
||||||
@@ -26,4 +27,23 @@ $instance->setConfig($config);
|
|||||||
|
|
||||||
$recharge = $instance->getRecharge();
|
$recharge = $instance->getRecharge();
|
||||||
$recharge->cashWithdrawal(1, 'xxx', 'ooo');
|
$recharge->cashWithdrawal(1, 'xxx', 'ooo');
|
||||||
|
$recharge->recharge(1, '', '');
|
||||||
|
|
||||||
|
$account = $instance->getAccount();
|
||||||
|
$account->setSavePath('');
|
||||||
|
$account->login('');
|
||||||
|
$account->createwxaqrcode('pages/index/index',200);
|
||||||
|
$account->getwxacode('pages/index/index',150,true);
|
||||||
|
$account->getwxacodeunlimit('pages/index/index',150,true);
|
||||||
|
|
||||||
|
|
||||||
|
$message = $instance->getMessage();
|
||||||
|
$message->setOpenid('');
|
||||||
|
$message->sendCardNews('');
|
||||||
|
|
||||||
|
$template = $instance->getTemplate();
|
||||||
|
$template->setOpenId('');
|
||||||
|
$template->setFormId('');
|
||||||
|
$template->setTemplateId('');
|
||||||
|
$template->setPage('');
|
||||||
|
$template->sendTemplate();
|
||||||
|
|||||||
+18
-1
@@ -69,7 +69,7 @@ class Config
|
|||||||
*
|
*
|
||||||
* 异步回调地址
|
* 异步回调地址
|
||||||
*/
|
*/
|
||||||
private $notify_url = "https://game-slave-trade-api.zhuangb123.com/recharge/notify";
|
private $notify_url = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
@@ -106,6 +106,23 @@ class Config
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
private $key = '';
|
private $key = '';
|
||||||
|
private $access_token = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getAccessToken(): string
|
||||||
|
{
|
||||||
|
return $this->access_token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $access_token
|
||||||
|
*/
|
||||||
|
public function setAccessToken(string $access_token)
|
||||||
|
{
|
||||||
|
$this->access_token = $access_token;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $remote_addr
|
* @param string $remote_addr
|
||||||
|
|||||||
+4
-24
@@ -6,7 +6,6 @@ namespace wchat;
|
|||||||
|
|
||||||
class Message extends Miniprogarampage
|
class Message extends Miniprogarampage
|
||||||
{
|
{
|
||||||
|
|
||||||
const TEXT = 0;
|
const TEXT = 0;
|
||||||
const IMAGE = 1;
|
const IMAGE = 1;
|
||||||
const VOICE = 2;
|
const VOICE = 2;
|
||||||
@@ -16,20 +15,9 @@ class Message extends Miniprogarampage
|
|||||||
const MINIPROGRAMPAGE = 6;
|
const MINIPROGRAMPAGE = 6;
|
||||||
const WXCARD = 7;
|
const WXCARD = 7;
|
||||||
|
|
||||||
|
|
||||||
private $type = self::TEXT;
|
|
||||||
|
|
||||||
private $openid = '';
|
private $openid = '';
|
||||||
private $msgData = [];
|
private $msgData = [];
|
||||||
private $token = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param int $type
|
|
||||||
*/
|
|
||||||
public function setType(int $type)
|
|
||||||
{
|
|
||||||
$this->type = $type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $openid
|
* @param string $openid
|
||||||
@@ -40,15 +28,6 @@ class Message extends Miniprogarampage
|
|||||||
$this->msgData['touser'] = $openid;
|
$this->msgData['touser'] = $openid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $token
|
|
||||||
*/
|
|
||||||
public function setToken(string $token)
|
|
||||||
{
|
|
||||||
$this->token = $token;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @return Result
|
* @return Result
|
||||||
@@ -216,10 +195,11 @@ class Message extends Miniprogarampage
|
|||||||
throw new \Exception('暂不支持的文件类型');
|
throw new \Exception('暂不支持的文件类型');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$token = $this->getAccessToken();
|
||||||
if ($isPermanent) {
|
if ($isPermanent) {
|
||||||
$url = "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token={$this->token}&type={$type}";
|
$url = "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token={$token}&type={$type}";
|
||||||
} else {
|
} else {
|
||||||
$url = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token={$this->token}&type={$type}";
|
$url = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token={$token}&type={$type}";
|
||||||
}
|
}
|
||||||
|
|
||||||
$mime = mime_content_type($filePath);
|
$mime = mime_content_type($filePath);
|
||||||
@@ -275,7 +255,7 @@ class Message extends Miniprogarampage
|
|||||||
{
|
{
|
||||||
$data = json_encode($this->msgData, JSON_UNESCAPED_UNICODE);
|
$data = json_encode($this->msgData, JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
$url = '/cgi-bin/message/custom/send?access_token=' . $this->token;
|
$url = '/cgi-bin/message/custom/send?access_token=' . $this->getAccessToken();
|
||||||
$this->request->setMethod(WxClient::POST);
|
$this->request->setMethod(WxClient::POST);
|
||||||
|
|
||||||
/** @var Result $body */
|
/** @var Result $body */
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ abstract class Miniprogarampage
|
|||||||
*/
|
*/
|
||||||
protected function getAccessToken()
|
protected function getAccessToken()
|
||||||
{
|
{
|
||||||
|
$access = $this->config->getAccessToken();
|
||||||
|
if (!empty($access)) {
|
||||||
|
return $access;
|
||||||
|
}
|
||||||
$this->request->setMethod(WxClient::GET);
|
$this->request->setMethod(WxClient::GET);
|
||||||
$data = $this->request->get('/cgi-bin/token', [
|
$data = $this->request->get('/cgi-bin/token', [
|
||||||
'grant_type' => 'client_credential',
|
'grant_type' => 'client_credential',
|
||||||
@@ -60,7 +64,9 @@ abstract class Miniprogarampage
|
|||||||
if (!$data->isResultsOK()) {
|
if (!$data->isResultsOK()) {
|
||||||
throw new \Exception($data->getMessage());
|
throw new \Exception($data->getMessage());
|
||||||
}
|
}
|
||||||
return $data->getData('access_token');
|
$access = $data->getData('access_token');
|
||||||
|
$this->config->setAccessToken($access);
|
||||||
|
return $access;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+4
-5
@@ -111,23 +111,22 @@ class Template extends Miniprogarampage
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $access
|
|
||||||
* @return Result
|
* @return Result
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*
|
*
|
||||||
* 奴隶交易通知
|
* 奴隶交易通知
|
||||||
*/
|
*/
|
||||||
public function sendTemplate(string $access)
|
public function sendTemplate()
|
||||||
{
|
{
|
||||||
$url = $this->sendUrl . '?access_token=' . $access;
|
$url = $this->sendUrl . '?access_token=' . $this->getAccessToken();
|
||||||
|
|
||||||
$params = [
|
$params = json_encode([
|
||||||
"touser" => $this->openId,
|
"touser" => $this->openId,
|
||||||
"template_id" => $this->templateId,
|
"template_id" => $this->templateId,
|
||||||
"page" => $this->page,
|
"page" => $this->page,
|
||||||
"form_id" => $this->formId,
|
"form_id" => $this->formId,
|
||||||
"data" => $this->keywords,
|
"data" => $this->keywords,
|
||||||
];
|
], JSON_UNESCAPED_UNICODE);
|
||||||
|
|
||||||
if (!empty($this->emphasis_keyword)) {
|
if (!empty($this->emphasis_keyword)) {
|
||||||
$params['emphasis_keyword'] = $this->emphasis_keyword;
|
$params['emphasis_keyword'] = $this->emphasis_keyword;
|
||||||
|
|||||||
+3
-3
@@ -171,11 +171,11 @@ class WxClient
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (strtolower($this->method)) {
|
switch (strtolower($this->method)) {
|
||||||
case self::POST:
|
case self::GET:
|
||||||
$client->post($url, $data);
|
$client->get($url);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$client->get($url);
|
$client->post($url, $data);
|
||||||
}
|
}
|
||||||
return $client;
|
return $client;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user