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

PHP Fatal error: Uncaught HttpException #517

Closed
apm1467 opened this issue Oct 14, 2016 · 1 comment
Closed

PHP Fatal error: Uncaught HttpException #517

apm1467 opened this issue Oct 14, 2016 · 1 comment

Comments

@apm1467
Copy link

apm1467 commented Oct 14, 2016

我用的环境

nginx/1.10.0 (Ubuntu)
PHP 7.0.8
overtrue/wechat 版本:3.1

问题及现象

按照官方文档在服务器上部署 server.php 后,使用

php server.php

命令直接运行,得到报错:

PHP Fatal error:  Uncaught EasyWeChat\Core\Exceptions\HttpException: invalid openid hint: [YTFzja0249ge10] in /var/www/html/vendor/overtrue/wechat/src/Core/AbstractAPI.php:235
Stack trace:
#0 /var/www/html/vendor/overtrue/wechat/src/Core/AbstractAPI.php(135): EasyWeChat\Core\AbstractAPI->checkAndThrow(Array)
#1 /var/www/html/vendor/overtrue/wechat/src/Notice/Notice.php(176): EasyWeChat\Core\AbstractAPI->parseJSON('json', Array)
#2 /var/www/html/server.php(40): EasyWeChat\Notice\Notice->send()
#3 {main}
  thrown in /var/www/html/vendor/overtrue/wechat/src/Core/AbstractAPI.php on line 235

附上 server.php 内容:

<?php
    include __DIR__ . '/vendor/autoload.php';
    use EasyWeChat\Foundation\Application;
    $options = [
        'debug'  => true,
        'app_id' => '', // 公众号信息隐去
        'secret' => '',
        'token'  => '',
        'aes_key' => '',
        'log' => [
            'level' => 'debug',
            'file'  => '/tmp/test.log', // 绝对路径
        ],

        //...
    ];
    $app = new Application($options);
    $server = $app->server;

    $server->setMessageHandler(function ($message) {
        return "您好!欢迎关注我!";
    });

    $notice = $app->notice;
    $userId = 'apm1467';
    templateId = 'OPENTM400096976';
    $url = '';
    $color = '#FF0000';
    $data = array(
         "first"  => "您好,您有新的余额变动",
         "keyword1"   => "今天",
         "keyword2"  => "39.8元",
         "keyword3"  => "39.8元",
         "remark" => "欢迎再次购买!",
        );

    $result = $notice->uses($templateId)->withUrl($url)->andData($data)->andReceiver($userId)->send();
    var_dump($result);

    $response = $server->serve();
    $response->send(); 
?>

@overtrue
Copy link
Collaborator

invalid openid

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