-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
好奇怪啊,开发者中心的服务器配置已经提交并验证成功了,可是message不起作用 #10
Comments
你服务器上有日志吗?看看有没有啥报错之类的 |
查看了服务器日志没有报错,点开firebug net标签,200状态,但是响应内容html是: |
require "./autoload.php";
use Overtrue\Wechat\Server;
$appId = 'myapp';
$token = 'testtoken';
$encodingAESKey = 'myaeskey';
$server = new Server($appId, $token, $encodingAESKey);
$server->on('message', function($message){
return "您好!欢迎关注 overtrue!";
});
// 貌似你少了这句
echo $server->serve(); |
echo这句是我注释掉了,但是我加了这句还是没有输出啊 |
我也碰到这问题了 <?php
use Overtrue\Wechat\Message;
use Overtrue\Wechat\Server;
class WechatController extends BaseController
{
public function test()
{
$appId = '***';
$appSecret = '***';
$token = '***';
$encodingAESKey = '***';
$server = new Server($appId, $token, $encodingAESKey);
// 监听所有类型
$server->on('message', function ($message) {
Log::error($message);
return Message::make('text')->content('您好!');
});
// 监听指定类型
$server->on('message', 'image', function ($message) {
return Message::make('text')->content('我们已经收到您发送的图片!');
});
// 监听所有事件
$server->on('event', function ($event) {
Log::error('收到取消关注事件,取消关注者openid: ' . $event['FromUserName']);
});
// 只监听指定类型事件
$server->on('event', 'subscribe', function ($event) {
Log::error('收到关注事件,关注者openid: ' . $event['FromUserName']);
return Message::make('text')->content('感谢您关注');
});
$result = $server->serve();
echo $result;
}
} |
@18601673727 你这是写在laravel里面的? 我是独立调用 |
@phoenixg 是的,无任何log或其他线索,routes.php里是这样的: Route::any('wechat', ['uses' => 'WechatController@test']); |
不光message不能用,event也不行的 |
@phoenixg @18601673727 不好意思,是一个隐形bug |
还是不行,"该公众号暂时无法提供服务,请稍后再试" |
更新了? |
肯定是最新版,因为我当时看到你关闭了这个issue,以为解决了 // 回调内
Log::info($message); // 正常json
Log::info(var_dump(Message::make('text')->content('您好'))); // [2015-05-04 17:47:40] production.INFO: [] []
// 回调外部
Log::info($result); // 正常xml
Log::info(var_dump($server)); // [2015-05-04 17:47:40] production.INFO: [] [] 我的Laravel 版本是4.2,未加入alias/provider,只是在<?php 后面use了一把,这个没关系吧? |
@phoenixg 你已经搞定啦? |
@18601673727 yes, download latest version and try, but I'm not using with laravel, I'm using the standalone version |
@18601673727 同学,var_dump没有返回值: Log::info(var_dump(Message::make('text')->content('您好'))); 应该是: Log::info(Message::make('text')->content('您好')); |
学到了,谢谢,不过在我写这些 |
@18601673727 好吧。。。 |
为什么用户给公众号发消息却收不到“您好!欢迎关注 overtrue!"“
The text was updated successfully, but these errors were encountered: