更新 Base.php

根据本地文件修改
This commit is contained in:
2019-05-21 16:01:05 +08:00
parent a20dd5b086
commit 3e4db2d5a5
+15 -10
View File
@@ -15,7 +15,7 @@ abstract class Base
*
* 小程序ID
*/
public $app_id = '';
public $appid = '';
/**
@@ -98,7 +98,7 @@ abstract class Base
/**
* @var string
*/
public $app_secret = '';
public $appsecret = '';
public $ssl_cert = '';
public $ssl_key = '';
@@ -130,12 +130,14 @@ abstract class Base
/**
*
*/
public function loadConfig($configPath)
public function loadConfig($config)
{
$config = require realpath($configPath);
if (empty($config)) {
return;
}
if (is_string($config)) {
$config = require_once $config;
}
foreach ($config as $key => $val) {
if (!property_exists($this, $key)) {
continue;
@@ -149,6 +151,7 @@ abstract class Base
* @param array $data
* @param callable|null $callback
* @return Result
* @throws
*/
public function push($url, $data = [], callable $callback = NULL)
{
@@ -181,7 +184,7 @@ abstract class Base
* @param array $data
* @return string
*/
protected function toXml(array $data)
public static function toXml(array $data)
{
$xml = "<xml>";
foreach ($data as $key => $val) {
@@ -245,8 +248,8 @@ abstract class Base
{
$data = Http::get('https://api.weixin.qq.com/cgi-bin/token', [
'grant_type' => 'client_credential',
'appid' => $this->app_id,
'secret' => $this->app_secret,
'appid' => $this->appid,
'secret' => $this->appsecret,
]);
if (!$data->isResultsOK()) {
@@ -339,7 +342,7 @@ abstract class Base
* @param $data
* @return int
*/
public static function decode($encryptedData, $iv, $sessionKey, &$data)
public static function decode($encryptedData, $iv, $sessionKey, &$data, $appId = null)
{
if (strlen($sessionKey) != 24) {
return self::$IllegalAesKey;
@@ -355,13 +358,15 @@ abstract class Base
$aesCipher = base64_decode($encryptedData);
$result = openssl_decrypt($aesCipher, "AES-128-CBC", $aesKey, 1, $aesIV);
$dataObj = json_decode($result);
if ($dataObj == NULL) {
return self::$IllegalBuffer;
}
if ($dataObj->watermark->appid != static::$app_id) {
if (empty($appId)) {
$appId = static::$app_id;
}
if ($dataObj->watermark->appid != $appId) {
return self::$IllegalBuffer;
}
$data = $dataObj;