This commit is contained in:
xl
2023-11-14 12:39:28 +08:00
parent c3326a9b5a
commit f92fdab692
15 changed files with 245 additions and 272 deletions
+9 -36
View File
@@ -9,7 +9,6 @@
namespace wchat\wx;
use Exception;
use wchat\common\Decode;
use wchat\common\Result;
class Account extends SmallProgram
@@ -26,7 +25,7 @@ class Account extends SmallProgram
$param['js_code'] = $code;
$param['grant_type'] = 'authorization_code';
return $this->get('/sns/jscode2session', $param);
return $this->get('api.weixin.qq.com', '/sns/jscode2session', $param);
}
/**
@@ -40,7 +39,7 @@ class Account extends SmallProgram
$param['js_code'] = $code;
$param['grant_type'] = 'authorization_code';
return $this->get('/sns/oauth2/access_token', $param);
return $this->get('api.weixin.qq.com', '/sns/oauth2/access_token', $param);
}
/**
@@ -55,7 +54,7 @@ class Account extends SmallProgram
'openid' => $openid,
'lang' => 'zh_CN'
];
return $this->get('/cgi-bin/user/info', $query);
return $this->get('api.weixin.qq.com', '/cgi-bin/user/info', $query);
}
/**
@@ -69,33 +68,7 @@ class Account extends SmallProgram
'access_token' => $this->payConfig->getAccessToken(),
'openid' => $openid,
];
return $this->get('/sns/userinfo', $query);
}
/**
* @param $encryptedData
* @param $iv
* @param $sessionKey
* @param bool $asArray
* @return object|array
* @throws
*
* * <li>-41001: encodingAesKey 非法</li>
* <li>-41003: aes 解密失败</li>
* <li>-41004: 解密后得到的buffer非法</li>
* <li>-41005: base64加密失败</li>
* <li>-41016: base64解密失败</li>
*/
public function decode($encryptedData, $iv, $sessionKey, bool $asArray = false): object|array
{
$decode = new Decode();
$decode->setSessionKey($sessionKey);
$decode->setEncryptedData($encryptedData);
$decode->setAppId($this->payConfig->getAppid());
$decode->setIv($iv);
return $decode->decode($asArray);
return $this->get('api.weixin.qq.com', '/sns/userinfo', $query);
}
@@ -111,7 +84,7 @@ class Account extends SmallProgram
$sendBody['path'] = $path;
$sendBody['width'] = $width;
return $this->get($url . $this->payConfig->getAccessToken(), $sendBody);
return $this->get('api.weixin.qq.com', $url . $this->payConfig->getAccessToken(), $sendBody);
}
@@ -129,11 +102,11 @@ class Account extends SmallProgram
$sendBody['width'] = $width;
$sendBody['auto_color'] = $auto_color;
$sendBody['is_hyaline'] = $is_hyaline;
$url = 'wxa/getwxacode?access_token=' . $this->getConfig()->getAccessToken();
$url = 'wxa/getwxacode?access_token=' . $this->payConfig->getAccessToken();
if ($auto_color) {
$sendBody['line_color'] = $line_color;
}
return $this->get($url . $this->payConfig->getAccessToken(), $sendBody);
return $this->get('api.weixin.qq.com', $url . $this->payConfig->getAccessToken(), $sendBody);
}
@@ -152,11 +125,11 @@ class Account extends SmallProgram
$sendBody['width'] = $width;
$sendBody['auto_color'] = $auto_color;
$sendBody['is_hyaline'] = $is_hyaline;
$url = 'wxa/getwxacodeunlimit?access_token=' . $this->getConfig()->getAccessToken();
$url = 'wxa/getwxacodeunlimit?access_token=' . $this->payConfig->getAccessToken();
if ($auto_color) {
$sendBody['line_color'] = $line_color;
}
return $this->get($url . $this->payConfig->getAccessToken(), $sendBody);
return $this->get('api.weixin.qq.com', $url . $this->payConfig->getAccessToken(), $sendBody);
}
}