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