Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用$server->getMessage();报错 #712

Closed
DukeAnn opened this issue May 23, 2017 · 5 comments
Closed

使用$server->getMessage();报错 #712

DukeAnn opened this issue May 23, 2017 · 5 comments

Comments

@DukeAnn
Copy link

DukeAnn commented May 23, 2017

我用的环境

PHP 版本:
overtrue/wechat 版本:

问题及现象

我打算用事件存储微信发送的消息,把 new Application($this->options) 实例传入了事件中,在监听里面打印用户发送的消息


public function handle(WechatMessageEvent $event)
{
$server = $event->wechat->server;
// 获取数组类型的 微信接口发送数据
$message = $server->getMessage();
Log::info($message['Content']);
}


$message = $server->getMessage();,使用时虽然数据能正常获取到但是会写日志一个error

EasyWeChat\Server\BadRequestException: Invalid request. in /home/wwwroot/wechat_admin/vendor/overtrue/wechat/src/Server/Guard.php:343

#0 /home/wwwroot/wechat_admin/app/Listeners/WechatMessageListener.php(34): EasyWeChat\Server\Guard->getMessage()
#1 [internal function]: App\Listeners\WechatMessageListener->handle(Object(App\Events\WechatMessageEvent))

@overtrue
Copy link
Collaborator

overtrue commented Jun 3, 2017

请不要使用浏览器来访问,这个东西是给微信服务器来调用的。

@overtrue overtrue closed this as completed Jun 3, 2017
@DukeAnn
Copy link
Author

DukeAnn commented Jun 5, 2017

不是浏览器访问的,是我写在微信接口中的一个监听事件里面了,用来存储用户发送的消息时调用的,就报错了

@overtrue
Copy link
Collaborator

overtrue commented Jun 5, 2017

那就是你的 Nginx 配置有问题了,query 部分丢了

@DukeAnn
Copy link
Author

DukeAnn commented Jun 7, 2017

laravel 的 nginx 文件该怎么配置,能提供一下完整样例嘛,这个虽然报错但是还是可以正常运行的。

@overtrue
Copy link
Collaborator

overtrue commented Jun 7, 2017

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants