w7corp / easywechat

📦 一个 PHP 微信 SDK
https://easywechat.com
MIT License
10.29k stars 2.4k forks source link

开放平台Credential "component_verify_ticket" does not exist in cache. #1718

Closed daivem closed 4 years ago

daivem commented 5 years ago

我用的环境

问题及现象

在调用getPreAuthorizationUrl()的时候会抛出异常 Credential "component_verify_ticket" does not exist in cache.

如果你不提供相关的代码,我不会做任何应答,直接 close,感谢!-->

发起的代码如下

<?php defined('BASEPATH') OR exit('No direct script access allowed');

use EasyWeChat\Factory;

class Wechat2 extends Core_Controller {

public function __construct()
{
    parent:: __construct();

}

public function test2()
{
    $config = array(
        /**
         * 账号基本信息,请从微信公众平台/开放平台获取
         */
        'app_id'  => 'xxxxxx',         // AppID
        'secret'  => 'xxxxxxxxxxxxx',     // AppSecret
        'token'   => 'abcd1234',          // Token
        'aes_key' => '',                    // EncodingAESKey,兼容与安全模式下请一定要填写!!!

         /**
          * 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
          * 使用自定义类名时,构造函数将会接收一个 `EasyWeChat\Kernel\Http\Response` 实例
          */
        'response_type' => 'array',

        /**
         * 日志配置
         *
         * level: 日志级别, 可选为:
         *         debug/info/notice/warning/error/critical/alert/emergency
         * path:日志文件位置(绝对路径!!!),要求可写权限
         */
        'log' => [
            'default' => 'dev', // 默认使用的 channel,生产环境可以改为下面的 prod
            'channels' => [
                // 测试环境
                'dev' => [
                    'driver' => 'single',
                    'path' => APPPATH . 'logs/wechat_open.log',
                    'level' => 'debug',
                ],
                // 生产环境
                'prod' => [
                    'driver' => 'daily',
                    'path' => APPPATH . 'logs/wechat_open.log',
                    'level' => 'info',
                ],
            ],
        ],

        /**
         * 接口请求相关配置,超时时间等,具体可用参数请参考:
         * http://docs.guzzlephp.org/en/stable/request-config.html
         *
         * - retries: 重试次数,默认 1,指定当 http 请求失败时重试的次数。
         * - retry_delay: 重试延迟间隔(单位:ms),默认 500
         * - log_template: 指定 HTTP 日志模板,请参考:https://github.com/guzzle/guzzle/blob/master/src/MessageFormatter.php
         */
        'http' => [
            'max_retries' => 1,
            'retry_delay' => 500,
            'timeout' => 5.0,
            // 'base_uri' => 'https://api.weixin.qq.com/', // 如果你在国外想要覆盖默认的 url 的时候才使用,根据不同的模块配置不同的 uri
        ],

        /**
         * OAuth 配置
         *
         * scopes:公众平台(snsapi_userinfo / snsapi_base),开放平台:snsapi_login
         * callback:OAuth授权完成后的回调页地址
         */
        'oauth' => [
            'scopes'   => ['snsapi_login'],
            'callback' => '/examples/oauth_callback.php',
        ],

    );

    $open = Factory::openPlatform($config);
    $url = $open -> getPreAuthorizationUrl('https://uc.mowo.cn/callback.php');
    header('Location:' . $url);
    exit;
}

}

daivem commented 5 years ago

debug_backtrace: array ( 0 => array ( 'function' => 'exception_handler_ajax', 'args' => array ( 0 => EasyWeChat\Kernel\Exceptions\RuntimeException::set_state(array( 'message' => 'Credential "component_verify_ticket" does not exist in cache.', 'string' => '', 'code' => 0, 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/overtrue/wechat/src/OpenPlatform/Auth/VerifyTicket.php', 'line' => 77, 'trace' => array ( 0 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/overtrue/wechat/src/OpenPlatform/Auth/AccessToken.php', 'line' => 46, 'function' => 'getTicket', 'class' => 'EasyWeChat\OpenPlatform\Auth\VerifyTicket', 'type' => '->', 'args' => array ( ), ), 1 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/overtrue/wechat/src/Kernel/AccessToken.php', 'line' => 231, 'function' => 'getCredentials', 'class' => 'EasyWeChat\OpenPlatform\Auth\AccessToken', 'type' => '->', 'args' => array ( ), ), 2 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/overtrue/wechat/src/Kernel/AccessToken.php', 'line' => 111, 'function' => 'getCacheKey', 'class' => 'EasyWeChat\Kernel\AccessToken', 'type' => '->', 'args' => array ( ), ), 3 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/overtrue/wechat/src/Kernel/AccessToken.php', 'line' => 247, 'function' => 'getToken', 'class' => 'EasyWeChat\Kernel\AccessToken', 'type' => '->', 'args' => array ( ), ), 4 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/overtrue/wechat/src/Kernel/AccessToken.php', 'line' => 203, 'function' => 'getQuery', 'class' => 'EasyWeChat\Kernel\AccessToken', 'type' => '->', 'args' => array ( ), ), 5 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/overtrue/wechat/src/Kernel/BaseClient.php', 'line' => 213, 'function' => 'applyToRequest', 'class' => 'EasyWeChat\Kernel\AccessToken', 'type' => '->', 'args' => array ( 0 => GuzzleHttp\Psr7\Request::__set_state(array( 'method' => 'POST', 'requestTarget' => NULL, 'uri' => GuzzleHttp\Psr7\Uri::set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/cgi-bin/component/api_create_preauthcode', 'query' => '', 'fragment' => '', )), 'headers' => array ( 'Content-Length' => array ( 0 => '40', ), 'User-Agent' => array ( 0 => 'GuzzleHttp/6.3.3 curl/7.58.0 PHP/7.2.19', ), 'Host' => array ( 0 => 'api.weixin.qq.com', ), 'Content-Type' => array ( 0 => 'application/json', ), ), 'headerNames' => array ( 'content-length' => 'Content-Length', 'user-agent' => 'User-Agent', 'host' => 'Host', 'content-type' => 'Content-Type', ), 'protocol' => '1.1', 'stream' => GuzzleHttp\Psr7\Stream::set_state(array( 'stream' => NULL, 'size' => 40, 'seekable' => true, 'readable' => true, 'writable' => true, 'uri' => 'php://temp', 'customMetadata' => array ( ), )), )), 1 => array ( 'curl' => array ( 113 => 1, ), 'handler' => GuzzleHttp\HandlerStack::__set_state(array( 'handler' => Closure::set_state(array( )), 'stack' => array ( 0 => array ( 0 => Closure::set_state(array( )), 1 => 'http_errors', ), 1 => array ( 0 => Closure::set_state(array( )), 1 => 'allow_redirects', ), 2 => array ( 0 => Closure::set_state(array( )), 1 => 'cookies', ), 3 => array ( 0 => Closure::set_state(array( )), 1 => 'prepare_body', ), 4 => array ( 0 => Closure::set_state(array( )), 1 => 'retry', ), 5 => array ( 0 => Closure::set_state(array( )), 1 => 'access_token', ), 6 => array ( 0 => Closure::set_state(array( )), 1 => 'log', ), ), 'cached' => Closure::set_state(array( )), )), 'synchronous' => true, 'timeout' => 5.0, 'base_uri' => GuzzleHttp\Psr7\Uri::set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/', 'query' => '', 'fragment' => '', )), 'max_retries' => 1, 'retry_delay' => 500, 'allow_redirects' => array ( 'max' => 5, 'protocols' => array ( 0 => 'http', 1 => 'https', ), 'strict' => false, 'referer' => false, 'track_redirects' => false, ), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false, 'retries' => 0, ), ), ), 6 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php', 'line' => 67, 'function' => 'EasyWeChat\Kernel\{closure}', 'class' => 'EasyWeChat\Kernel\BaseClient', 'type' => '->', 'args' => array ( 0 => GuzzleHttp\Psr7\Request::set_state(array( 'method' => 'POST', 'requestTarget' => NULL, 'uri' => GuzzleHttp\Psr7\Uri::set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/cgi-bin/component/api_create_preauthcode', 'query' => '', 'fragment' => '', )), 'headers' => array ( 'Content-Length' => array ( 0 => '40', ), 'User-Agent' => array ( 0 => 'GuzzleHttp/6.3.3 curl/7.58.0 PHP/7.2.19', ), 'Host' => array ( 0 => 'api.weixin.qq.com', ), 'Content-Type' => array ( 0 => 'application/json', ), ), 'headerNames' => array ( 'content-length' => 'Content-Length', 'user-agent' => 'User-Agent', 'host' => 'Host', 'content-type' => 'Content-Type', ), 'protocol' => '1.1', 'stream' => GuzzleHttp\Psr7\Stream::__set_state(array( 'stream' => NULL, 'size' => 40, 'seekable' => true, 'readable' => true, 'writable' => true, 'uri' => 'php://temp', 'customMetadata' => array ( ), )), )), 1 => array ( 'curl' => array ( 113 => 1, ), 'handler' => GuzzleHttp\HandlerStack::set_state(array( 'handler' => Closure::set_state(array( )), 'stack' => array ( 0 => array ( 0 => Closure::set_state(array( )), 1 => 'http_errors', ), 1 => array ( 0 => Closure::set_state(array( )), 1 => 'allow_redirects', ), 2 => array ( 0 => Closure::__set_state(array( )), 1 => 'cookies', ), 3 => array ( 0 => Closure::set_state(array( )), 1 => 'prepare_body', ), 4 => array ( 0 => Closure::set_state(array( )), 1 => 'retry', ), 5 => array ( 0 => Closure::set_state(array( )), 1 => 'access_token', ), 6 => array ( 0 => Closure::set_state(array( )), 1 => 'log', ), ), 'cached' => Closure::set_state(array( )), )), 'synchronous' => true, 'timeout' => 5.0, 'base_uri' => GuzzleHttp\Psr7\Uri::set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/', 'query' => '', 'fragment' => '', )), 'max_retries' => 1, 'retry_delay' => 500, 'allow_redirects' => array ( 'max' => 5, 'protocols' => array ( 0 => 'http', 1 => 'https', ), 'strict' => false, 'referer' => false, 'track_redirects' => false, ), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false, 'retries' => 0, ), ), ), 7 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php', 'line' => 66, 'function' => 'invoke', 'class' => 'GuzzleHttp\RetryMiddleware', 'type' => '->', 'args' => array ( 0 => GuzzleHttp\Psr7\Request::set_state(array( 'method' => 'POST', 'requestTarget' => NULL, 'uri' => GuzzleHttp\Psr7\Uri::set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/cgi-bin/component/api_create_preauthcode', 'query' => '', 'fragment' => '', )), 'headers' => array ( 'Content-Length' => array ( 0 => '40', ), 'User-Agent' => array ( 0 => 'GuzzleHttp/6.3.3 curl/7.58.0 PHP/7.2.19', ), 'Host' => array ( 0 => 'api.weixin.qq.com', ), 'Content-Type' => array ( 0 => 'application/json', ), ), 'headerNames' => array ( 'content-length' => 'Content-Length', 'user-agent' => 'User-Agent', 'host' => 'Host', 'content-type' => 'Content-Type', ), 'protocol' => '1.1', 'stream' => GuzzleHttp\Psr7\Stream::set_state(array( 'stream' => NULL, 'size' => 40, 'seekable' => true, 'readable' => true, 'writable' => true, 'uri' => 'php://temp', 'customMetadata' => array ( ), )), )), 1 => array ( 'curl' => array ( 113 => 1, ), 'handler' => GuzzleHttp\HandlerStack::__set_state(array( 'handler' => Closure::set_state(array( )), 'stack' => array ( 0 => array ( 0 => Closure::set_state(array( )), 1 => 'http_errors', ), 1 => array ( 0 => Closure::set_state(array( )), 1 => 'allow_redirects', ), 2 => array ( 0 => Closure::set_state(array( )), 1 => 'cookies', ), 3 => array ( 0 => Closure::set_state(array( )), 1 => 'prepare_body', ), 4 => array ( 0 => Closure::set_state(array( )), 1 => 'retry', ), 5 => array ( 0 => Closure::set_state(array( )), 1 => 'access_token', ), 6 => array ( 0 => Closure::set_state(array( )), 1 => 'log', ), ), 'cached' => Closure::set_state(array( )), )), 'synchronous' => true, 'timeout' => 5.0, 'base_uri' => GuzzleHttp\Psr7\Uri::set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/', 'query' => '', 'fragment' => '', )), 'max_retries' => 1, 'retry_delay' => 500, 'allow_redirects' => array ( 'max' => 5, 'protocols' => array ( 0 => 'http', 1 => 'https', ), 'strict' => false, 'referer' => false, 'track_redirects' => false, ), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false, 'retries' => 0, ), ), ), 8 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/guzzlehttp/guzzle/src/Middleware.php', 'line' => 30, 'function' => 'invoke', 'class' => 'GuzzleHttp\PrepareBodyMiddleware', 'type' => '->', 'args' => array ( 0 => GuzzleHttp\Psr7\Request::set_state(array( 'method' => 'POST', 'requestTarget' => NULL, 'uri' => GuzzleHttp\Psr7\Uri::__set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/cgi-bin/component/api_create_preauthcode', 'query' => '', 'fragment' => '', )), 'headers' => array ( 'User-Agent' => array ( 0 => 'GuzzleHttp/6.3.3 curl/7.58.0 PHP/7.2.19', ), 'Host' => array ( 0 => 'api.weixin.qq.com', ), 'Content-Type' => array ( 0 => 'application/json', ), ), 'headerNames' => array ( 'user-agent' => 'User-Agent', 'host' => 'Host', 'content-type' => 'Content-Type', ), 'protocol' => '1.1', 'stream' => GuzzleHttp\Psr7\Stream::set_state(array( 'stream' => NULL, 'size' => 40, 'seekable' => true, 'readable' => true, 'writable' => true, 'uri' => 'php://temp', 'customMetadata' => array ( ), )), )), 1 => array ( 'curl' => array ( 113 => 1, ), 'handler' => GuzzleHttp\HandlerStack::set_state(array( 'handler' => Closure::__set_state(array( )), 'stack' => array ( 0 => array ( 0 => Closure::set_state(array( )), 1 => 'http_errors', ), 1 => array ( 0 => Closure::set_state(array( )), 1 => 'allow_redirects', ), 2 => array ( 0 => Closure::set_state(array( )), 1 => 'cookies', ), 3 => array ( 0 => Closure::set_state(array( )), 1 => 'prepare_body', ), 4 => array ( 0 => Closure::set_state(array( )), 1 => 'retry', ), 5 => array ( 0 => Closure::set_state(array( )), 1 => 'access_token', ), 6 => array ( 0 => Closure::set_state(array( )), 1 => 'log', ), ), 'cached' => Closure::set_state(array( )), )), 'synchronous' => true, 'timeout' => 5.0, 'base_uri' => GuzzleHttp\Psr7\Uri::set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/', 'query' => '', 'fragment' => '', )), 'max_retries' => 1, 'retry_delay' => 500, 'allow_redirects' => array ( 'max' => 5, 'protocols' => array ( 0 => 'http', 1 => 'https', ), 'strict' => false, 'referer' => false, 'track_redirects' => false, ), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false, ), ), ), 9 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php', 'line' => 70, 'function' => 'GuzzleHttp\{closure}', 'class' => 'GuzzleHttp\Middleware', 'type' => '::', 'args' => array ( 0 => GuzzleHttp\Psr7\Request::set_state(array( 'method' => 'POST', 'requestTarget' => NULL, 'uri' => GuzzleHttp\Psr7\Uri::__set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/cgi-bin/component/api_create_preauthcode', 'query' => '', 'fragment' => '', )), 'headers' => array ( 'User-Agent' => array ( 0 => 'GuzzleHttp/6.3.3 curl/7.58.0 PHP/7.2.19', ), 'Host' => array ( 0 => 'api.weixin.qq.com', ), 'Content-Type' => array ( 0 => 'application/json', ), ), 'headerNames' => array ( 'user-agent' => 'User-Agent', 'host' => 'Host', 'content-type' => 'Content-Type', ), 'protocol' => '1.1', 'stream' => GuzzleHttp\Psr7\Stream::set_state(array( 'stream' => NULL, 'size' => 40, 'seekable' => true, 'readable' => true, 'writable' => true, 'uri' => 'php://temp', 'customMetadata' => array ( ), )), )), 1 => array ( 'curl' => array ( 113 => 1, ), 'handler' => GuzzleHttp\HandlerStack::set_state(array( 'handler' => Closure::__set_state(array( )), 'stack' => array ( 0 => array ( 0 => Closure::set_state(array( )), 1 => 'http_errors', ), 1 => array ( 0 => Closure::set_state(array( )), 1 => 'allow_redirects', ), 2 => array ( 0 => Closure::set_state(array( )), 1 => 'cookies', ), 3 => array ( 0 => Closure::set_state(array( )), 1 => 'prepare_body', ), 4 => array ( 0 => Closure::set_state(array( )), 1 => 'retry', ), 5 => array ( 0 => Closure::set_state(array( )), 1 => 'access_token', ), 6 => array ( 0 => Closure::set_state(array( )), 1 => 'log', ), ), 'cached' => Closure::set_state(array( )), )), 'synchronous' => true, 'timeout' => 5.0, 'base_uri' => GuzzleHttp\Psr7\Uri::set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/', 'query' => '', 'fragment' => '', )), 'max_retries' => 1, 'retry_delay' => 500, 'allow_redirects' => array ( 'max' => 5, 'protocols' => array ( 0 => 'http', 1 => 'https', ), 'strict' => false, 'referer' => false, 'track_redirects' => false, ), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false, ), ), ), 10 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/guzzlehttp/guzzle/src/Middleware.php', 'line' => 60, 'function' => 'invoke', 'class' => 'GuzzleHttp\RedirectMiddleware', 'type' => '->', 'args' => array ( 0 => GuzzleHttp\Psr7\Request::set_state(array( 'method' => 'POST', 'requestTarget' => NULL, 'uri' => GuzzleHttp\Psr7\Uri::set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/cgi-bin/component/api_create_preauthcode', 'query' => '', 'fragment' => '', )), 'headers' => array ( 'User-Agent' => array ( 0 => 'GuzzleHttp/6.3.3 curl/7.58.0 PHP/7.2.19', ), 'Host' => array ( 0 => 'api.weixin.qq.com', ), 'Content-Type' => array ( 0 => 'application/json', ), ), 'headerNames' => array ( 'user-agent' => 'User-Agent', 'host' => 'Host', 'content-type' => 'Content-Type', ), 'protocol' => '1.1', 'stream' => GuzzleHttp\Psr7\Stream::__set_state(array( 'stream' => NULL, 'size' => 40, 'seekable' => true, 'readable' => true, 'writable' => true, 'uri' => 'php://temp', 'customMetadata' => array ( ), )), )), 1 => array ( 'curl' => array ( 113 => 1, ), 'handler' => GuzzleHttp\HandlerStack::set_state(array( 'handler' => Closure::set_state(array( )), 'stack' => array ( 0 => array ( 0 => Closure::set_state(array( )), 1 => 'http_errors', ), 1 => array ( 0 => Closure::set_state(array( )), 1 => 'allow_redirects', ), 2 => array ( 0 => Closure::__set_state(array( )), 1 => 'cookies', ), 3 => array ( 0 => Closure::set_state(array( )), 1 => 'prepare_body', ), 4 => array ( 0 => Closure::set_state(array( )), 1 => 'retry', ), 5 => array ( 0 => Closure::set_state(array( )), 1 => 'access_token', ), 6 => array ( 0 => Closure::set_state(array( )), 1 => 'log', ), ), 'cached' => Closure::set_state(array( )), )), 'synchronous' => true, 'timeout' => 5.0, 'base_uri' => GuzzleHttp\Psr7\Uri::set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/', 'query' => '', 'fragment' => '', )), 'max_retries' => 1, 'retry_delay' => 500, 'allow_redirects' => array ( 'max' => 5, 'protocols' => array ( 0 => 'http', 1 => 'https', ), 'strict' => false, 'referer' => false, 'track_redirects' => false, ), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false, ), ), ), 11 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/guzzlehttp/guzzle/src/HandlerStack.php', 'line' => 67, 'function' => 'GuzzleHttp\{closure}', 'class' => 'GuzzleHttp\Middleware', 'type' => '::', 'args' => array ( 0 => GuzzleHttp\Psr7\Request::__set_state(array( 'method' => 'POST', 'requestTarget' => NULL, 'uri' => GuzzleHttp\Psr7\Uri::set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/cgi-bin/component/api_create_preauthcode', 'query' => '', 'fragment' => '', )), 'headers' => array ( 'User-Agent' => array ( 0 => 'GuzzleHttp/6.3.3 curl/7.58.0 PHP/7.2.19', ), 'Host' => array ( 0 => 'api.weixin.qq.com', ), 'Content-Type' => array ( 0 => 'application/json', ), ), 'headerNames' => array ( 'user-agent' => 'User-Agent', 'host' => 'Host', 'content-type' => 'Content-Type', ), 'protocol' => '1.1', 'stream' => GuzzleHttp\Psr7\Stream::set_state(array( 'stream' => NULL, 'size' => 40, 'seekable' => true, 'readable' => true, 'writable' => true, 'uri' => 'php://temp', 'customMetadata' => array ( ), )), )), 1 => array ( 'curl' => array ( 113 => 1, ), 'handler' => GuzzleHttp\HandlerStack::__set_state(array( 'handler' => Closure::set_state(array( )), 'stack' => array ( 0 => array ( 0 => Closure::set_state(array( )), 1 => 'http_errors', ), 1 => array ( 0 => Closure::set_state(array( )), 1 => 'allow_redirects', ), 2 => array ( 0 => Closure::set_state(array( )), 1 => 'cookies', ), 3 => array ( 0 => Closure::set_state(array( )), 1 => 'prepare_body', ), 4 => array ( 0 => Closure::set_state(array( )), 1 => 'retry', ), 5 => array ( 0 => Closure::set_state(array( )), 1 => 'access_token', ), 6 => array ( 0 => Closure::set_state(array( )), 1 => 'log', ), ), 'cached' => Closure::set_state(array( )), )), 'synchronous' => true, 'timeout' => 5.0, 'base_uri' => GuzzleHttp\Psr7\Uri::set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/', 'query' => '', 'fragment' => '', )), 'max_retries' => 1, 'retry_delay' => 500, 'allow_redirects' => array ( 'max' => 5, 'protocols' => array ( 0 => 'http', 1 => 'https', ), 'strict' => false, 'referer' => false, 'track_redirects' => false, ), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false, ), ), ), 12 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/guzzlehttp/guzzle/src/Client.php', 'line' => 277, 'function' => 'invoke', 'class' => 'GuzzleHttp\HandlerStack', 'type' => '->', 'args' => array ( 0 => GuzzleHttp\Psr7\Request::set_state(array( 'method' => 'POST', 'requestTarget' => NULL, 'uri' => GuzzleHttp\Psr7\Uri::__set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/cgi-bin/component/api_create_preauthcode', 'query' => '', 'fragment' => '', )), 'headers' => array ( 'User-Agent' => array ( 0 => 'GuzzleHttp/6.3.3 curl/7.58.0 PHP/7.2.19', ), 'Host' => array ( 0 => 'api.weixin.qq.com', ), 'Content-Type' => array ( 0 => 'application/json', ), ), 'headerNames' => array ( 'user-agent' => 'User-Agent', 'host' => 'Host', 'content-type' => 'Content-Type', ), 'protocol' => '1.1', 'stream' => GuzzleHttp\Psr7\Stream::set_state(array( 'stream' => NULL, 'size' => 40, 'seekable' => true, 'readable' => true, 'writable' => true, 'uri' => 'php://temp', 'customMetadata' => array ( ), )), )), 1 => array ( 'curl' => array ( 113 => 1, ), 'handler' => GuzzleHttp\HandlerStack::set_state(array( 'handler' => Closure::__set_state(array( )), 'stack' => array ( 0 => array ( 0 => Closure::set_state(array( )), 1 => 'http_errors', ), 1 => array ( 0 => Closure::set_state(array( )), 1 => 'allow_redirects', ), 2 => array ( 0 => Closure::set_state(array( )), 1 => 'cookies', ), 3 => array ( 0 => Closure::set_state(array( )), 1 => 'prepare_body', ), 4 => array ( 0 => Closure::set_state(array( )), 1 => 'retry', ), 5 => array ( 0 => Closure::set_state(array( )), 1 => 'access_token', ), 6 => array ( 0 => Closure::set_state(array( )), 1 => 'log', ), ), 'cached' => Closure::set_state(array( )), )), 'synchronous' => true, 'timeout' => 5.0, 'base_uri' => GuzzleHttp\Psr7\Uri::set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/', 'query' => '', 'fragment' => '', )), 'max_retries' => 1, 'retry_delay' => 500, 'allow_redirects' => array ( 'max' => 5, 'protocols' => array ( 0 => 'http', 1 => 'https', ), 'strict' => false, 'referer' => false, 'track_redirects' => false, ), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false, ), ), ), 13 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/guzzlehttp/guzzle/src/Client.php', 'line' => 125, 'function' => 'transfer', 'class' => 'GuzzleHttp\Client', 'type' => '->', 'args' => array ( 0 => GuzzleHttp\Psr7\Request::set_state(array( 'method' => 'POST', 'requestTarget' => NULL, 'uri' => GuzzleHttp\Psr7\Uri::__set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/cgi-bin/component/api_create_preauthcode', 'query' => '', 'fragment' => '', )), 'headers' => array ( 'User-Agent' => array ( 0 => 'GuzzleHttp/6.3.3 curl/7.58.0 PHP/7.2.19', ), 'Host' => array ( 0 => 'api.weixin.qq.com', ), 'Content-Type' => array ( 0 => 'application/json', ), ), 'headerNames' => array ( 'user-agent' => 'User-Agent', 'host' => 'Host', 'content-type' => 'Content-Type', ), 'protocol' => '1.1', 'stream' => GuzzleHttp\Psr7\Stream::set_state(array( 'stream' => NULL, 'size' => 40, 'seekable' => true, 'readable' => true, 'writable' => true, 'uri' => 'php://temp', 'customMetadata' => array ( ), )), )), 1 => array ( 'curl' => array ( 113 => 1, ), 'handler' => GuzzleHttp\HandlerStack::set_state(array( 'handler' => Closure::__set_state(array( )), 'stack' => array ( 0 => array ( 0 => Closure::set_state(array( )), 1 => 'http_errors', ), 1 => array ( 0 => Closure::set_state(array( )), 1 => 'allow_redirects', ), 2 => array ( 0 => Closure::set_state(array( )), 1 => 'cookies', ), 3 => array ( 0 => Closure::set_state(array( )), 1 => 'prepare_body', ), 4 => array ( 0 => Closure::set_state(array( )), 1 => 'retry', ), 5 => array ( 0 => Closure::set_state(array( )), 1 => 'access_token', ), 6 => array ( 0 => Closure::set_state(array( )), 1 => 'log', ), ), 'cached' => Closure::set_state(array( )), )), 'synchronous' => true, 'timeout' => 5.0, 'base_uri' => GuzzleHttp\Psr7\Uri::set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/', 'query' => '', 'fragment' => '', )), 'max_retries' => 1, 'retry_delay' => 500, 'allow_redirects' => array ( 'max' => 5, 'protocols' => array ( 0 => 'http', 1 => 'https', ), 'strict' => false, 'referer' => false, 'track_redirects' => false, ), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false, ), ), ), 14 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/guzzlehttp/guzzle/src/Client.php', 'line' => 131, 'function' => 'requestAsync', 'class' => 'GuzzleHttp\Client', 'type' => '->', 'args' => array ( 0 => 'POST', 1 => GuzzleHttp\Psr7\Uri::set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/cgi-bin/component/api_create_preauthcode', 'query' => '', 'fragment' => '', )), 2 => array ( 'curl' => array ( 113 => 1, ), 'query' => array ( ), 'handler' => GuzzleHttp\HandlerStack::__set_state(array( 'handler' => Closure::set_state(array( )), 'stack' => array ( 0 => array ( 0 => Closure::set_state(array( )), 1 => 'http_errors', ), 1 => array ( 0 => Closure::set_state(array( )), 1 => 'allow_redirects', ), 2 => array ( 0 => Closure::set_state(array( )), 1 => 'cookies', ), 3 => array ( 0 => Closure::set_state(array( )), 1 => 'prepare_body', ), 4 => array ( 0 => Closure::set_state(array( )), 1 => 'retry', ), 5 => array ( 0 => Closure::set_state(array( )), 1 => 'access_token', ), 6 => array ( 0 => Closure::set_state(array( )), 1 => 'log', ), ), 'cached' => Closure::set_state(array( )), )), 'synchronous' => true, 'timeout' => 5.0, 'base_uri' => GuzzleHttp\Psr7\Uri::set_state(array( 'scheme' => 'https', 'userInfo' => '', 'host' => 'api.weixin.qq.com', 'port' => NULL, 'path' => '/', 'query' => '', 'fragment' => '', )), 'max_retries' => 1, 'retry_delay' => 500, 'allow_redirects' => array ( 'max' => 5, 'protocols' => array ( 0 => 'http', 1 => 'https', ), 'strict' => false, 'referer' => false, 'track_redirects' => false, ), 'http_errors' => true, 'decode_content' => true, 'verify' => true, 'cookies' => false, '_conditional' => array ( 'User-Agent' => 'GuzzleHttp/6.3.3 curl/7.58.0 PHP/7.2.19', ), ), ), ), 15 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/overtrue/wechat/src/Kernel/Traits/HasHttpRequests.php', 'line' => 154, 'function' => 'request', 'class' => 'GuzzleHttp\Client', 'type' => '->', 'args' => array ( 0 => 'POST', 1 => 'cgi-bin/component/api_create_preauthcode', 2 => array ( 'curl' => array ( 113 => 1, ), 'query' => array ( ), 'handler' => GuzzleHttp\HandlerStack::__set_state(array( 'handler' => Closure::set_state(array( )), 'stack' => array ( 0 => array ( 0 => Closure::set_state(array( )), 1 => 'http_errors', ), 1 => array ( 0 => Closure::set_state(array( )), 1 => 'allow_redirects', ), 2 => array ( 0 => Closure::set_state(array( )), 1 => 'cookies', ), 3 => array ( 0 => Closure::set_state(array( )), 1 => 'prepare_body', ), 4 => array ( 0 => Closure::set_state(array( )), 1 => 'retry', ), 5 => array ( 0 => Closure::set_state(array( )), 1 => 'access_token', ), 6 => array ( 0 => Closure::set_state(array( )), 1 => 'log', ), ), 'cached' => Closure::set_state(array( )), )), 'headers' => array ( 'Content-Type' => 'application/json', ), 'body' => '{"component_appid":"wx3e3b1174ba963d6f"}', 'synchronous' => true, ), ), ), 16 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/overtrue/wechat/src/Kernel/BaseClient.php', 'line' => 171, 'function' => 'performRequest', 'class' => 'EasyWeChat\Kernel\BaseClient', 'type' => '->', 'args' => array ( 0 => 'cgi-bin/component/api_create_preauthcode', 1 => 'POST', 2 => array ( 'curl' => array ( 113 => 1, ), 'query' => array ( ), 'handler' => GuzzleHttp\HandlerStack::set_state(array( 'handler' => Closure::set_state(array( )), 'stack' => array ( 0 => array ( 0 => Closure::set_state(array( )), 1 => 'http_errors', ), 1 => array ( 0 => Closure::set_state(array( )), 1 => 'allow_redirects', ), 2 => array ( 0 => Closure::set_state(array( )), 1 => 'cookies', ), 3 => array ( 0 => Closure::set_state(array( )), 1 => 'prepare_body', ), 4 => array ( 0 => Closure::set_state(array( )), 1 => 'retry', ), 5 => array ( 0 => Closure::set_state(array( )), 1 => 'access_token', ), 6 => array ( 0 => Closure::__set_state(array( )), 1 => 'log', ), ), 'cached' => Closure::set_state(array( )), )), 'headers' => array ( 'Content-Type' => 'application/json', ), 'body' => '{"component_appid":"wx3e3b1174ba963d6f"}', ), ), ), 17 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/overtrue/wechat/src/Kernel/BaseClient.php', 'line' => 102, 'function' => 'request', 'class' => 'EasyWeChat\Kernel\BaseClient', 'type' => '->', 'args' => array ( 0 => 'cgi-bin/component/api_create_preauthcode', 1 => 'POST', 2 => array ( 'query' => array ( ), 'json' => array ( 'component_appid' => 'wx3e3b1174ba963d6f', ), ), ), ), 18 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/overtrue/wechat/src/OpenPlatform/Base/Client.php', 'line' => 127, 'function' => 'httpPostJson', 'class' => 'EasyWeChat\Kernel\BaseClient', 'type' => '->', 'args' => array ( 0 => 'cgi-bin/component/api_create_preauthcode', 1 => array ( 'component_appid' => 'wx3e3b1174ba963d6f', ), ), ), 19 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/overtrue/wechat/src/OpenPlatform/Application.php', 'line' => 218, 'function' => 'createPreAuthorizationCode', 'class' => 'EasyWeChat\OpenPlatform\Base\Client', 'type' => '->', 'args' => array ( ), ), 20 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/overtrue/wechat/src/OpenPlatform/Application.php', 'line' => 127, 'function' => 'call', 'class' => 'EasyWeChat\OpenPlatform\Application', 'type' => '->', 'args' => array ( 0 => 'createPreAuthorizationCode', 1 => array ( ), ), ), 21 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/application/controllers/Wechat2.php', 'line' => 97, 'function' => 'getPreAuthorizationUrl', 'class' => 'EasyWeChat\OpenPlatform\Application', 'type' => '->', 'args' => array ( 0 => 'https://uc.mowo.cn/callback.php', ), ), 22 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/system/core/CodeIgniter.php', 'line' => 532, 'function' => 'test2', 'class' => 'Wechat2', 'type' => '->', 'args' => array ( ), ), 23 => array ( 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/web/index.php', 'line' => 316, 'args' => array ( 0 => '/home/dv/myweb/mowo-svn/mowo-ucenter/system/core/CodeIgniter.php', ), 'function' => 'require_once', ), ), 'previous' => NULL, )), ), ), ) <?php exit; ?>|11409445|2019-11-04 11:08:44|192.168.80.1|ERR|exception_helper.php:51|uncatch error: array ( 'message' => 'Credential "component_verify_ticket" does not exist in cache.', 'code' => 0, 'file' => '/home/dv/myweb/mowo-svn/mowo-ucenter/vendor/overtrue/wechat/src/OpenPlatform/Auth/VerifyTicket.php', 'line' => 77, ) <?php exit; ?>|11409445|2019-11-04 11:08:44|192.168.80.1|INF|common_helper.php:23|result: -999 message: 系统异常被捕捉:Credential "component_verify_ticket" does not exist in cache.

mingyoung commented 5 years ago

你知道 component_verify_ticket 是怎么来的吗?

daivem commented 5 years ago

/vendor/guzzlehttp/guzzle/src/Client.php 行277 在try的地方抛出来的

private function transfer(RequestInterface $request, array $options)

{ // save_to -> sink if (isset($options['save_to'])) { $options['sink'] = $options['save_to']; unset($options['save_to']); }

    // exceptions -> http_errors
    if (isset($options['exceptions'])) {
        $options['http_errors'] = $options['exceptions'];
        unset($options['exceptions']);
    }

    $request = $this->applyOptions($request, $options);
    $handler = $options['handler'];

    try {
        return Promise\promise_for($handler($request, $options));
    } catch (\Exception $e) {
        return Promise\rejection_for($e);
    }
}
mingyoung commented 5 years ago

建议先看懂流程: https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/api/component_verify_ticket.html

验证票据 | 微信开放文档
微信开发者平台文档
daivem commented 5 years ago

十分感谢,我先看看