This commit is contained in:
2024-05-07 14:42:30 +08:00
parent a3aa8e8ac3
commit aeb4f3d7fb
+23 -21
View File
@@ -6,25 +6,27 @@ namespace wchat\wx;
use wchat\common\Result; use wchat\common\Result;
enum Scene //if (PHP_VERSION > '8.2') {
{ // enum Scene
// {
case SCENE_INFO; //
case SCENE_REPLY; // case SCENE_INFO;
case SCENE_DISCAZ; // case SCENE_REPLY;
case SCENE_SHEJIAO; // case SCENE_DISCAZ;
// case SCENE_SHEJIAO;
//
public function getValue(): int //
{ // public function getValue(): int
return match ($this) { // {
self::SCENE_INFO => 1, // return match ($this) {
self::SCENE_REPLY => 2, // self::SCENE_INFO => 1,
self::SCENE_DISCAZ => 3, // self::SCENE_REPLY => 2,
self::SCENE_SHEJIAO => 4, // self::SCENE_DISCAZ => 3,
}; // self::SCENE_SHEJIAO => 4,
} // };
} // }
// }
//}
/** /**
@@ -90,7 +92,7 @@ class SecCheck extends SmallProgram
* @param string $openId * @param string $openId
* @return Result * @return Result
*/ */
public function text(string $content, Scene $scene, string $openId): Result public function text(string $content, int $scene, string $openId): Result
{ {
if (empty($content)) { if (empty($content)) {
return $this->sendError('文件不存在', 404); return $this->sendError('文件不存在', 404);
@@ -100,7 +102,7 @@ class SecCheck extends SmallProgram
return $this->post('api.weixin.qq.com', $requestUrl, json_encode([ return $this->post('api.weixin.qq.com', $requestUrl, json_encode([
'content' => $content, 'content' => $content,
'version' => 2, 'version' => 2,
'scene' => $scene->getValue(), 'scene' => $scene,
'openid' => $openId 'openid' => $openId
], JSON_UNESCAPED_UNICODE), 'application/json'); ], JSON_UNESCAPED_UNICODE), 'application/json');
} }