Replies: 1 comment
|
This GET request is the WeChat server verification request, so it does not contain an XML/JSON message body. getRequestMessage() tries to parse the request body, which is why you get: Failed to decode content. Content must be valid XML or JSON. For the verification request, just let EasyWeChat handle it: Route::get('/aiw', function () {
$app = new Application(Config::get('easywechat.work.default'));
return $app->getServer()->serve();
});Then handle actual pushed messages on the POST request. Those requests contain the message body that getRequestMessage() can parse. Also, don't force messageType: 'son unless WeChat is actually sending JSON. WeChat server callbacks are commonly XML depending on the API/configuration. So the issue is not Laravel or PHP 8.3 — you are trying to parse the GET verification request as a message. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
EasyWeChat\Kernel\Exceptions\BadRequestException
vendor\w7corp\easywechat\src\Kernel\Support\MessageParser.php:39
Failed to decode content. Content must be valid XML or JSON.
LARAVEL13.19.0
PHP8.3.3
http://127.0.0.1:8000/aiw?echostr=V%2FEGfWKT%2FqR7%2FCOy%2Fun4UZ4Vg6BchnYGxLvPC1wC5DAKVKib%2Fo0xRzffvic6rwTV1xRYzB21HwtOET6mGZBW9g%3D%3D&msg_signature=b259d61249e3c3784016846ae1775a8b35b4dcfd&nonce=1786072394×tamp=1785916252
Route::get('/aiw', function () {
$app = new Application(Config::get('easywechat.work.default'));
// 指定消息格式 JSON
$server = $app->getServer(messageType: 'json');
dd($server->getRequestMessage());
})
All reactions