菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
94
0

hyperf 接入 easywechat

原创
05/13 14:22
阅读数 376

easyweacht是基于fpm模式开发的

不能直接在hyperf或者其他的swoole框架中直接食用

//实例化公众号 小程序 支付同理
$app = Factory::officialAccount(config('officialAccount'));

$config = $app['config']->get('http', []);

$config['handler'] = di()->get(HandlerStackFactory::class)->create();

$app->rebind('http_client', new Client($config));

// 重写 Handler
$app['guzzle_handler'] = new CoroutineHandler();

AbstractProvider::setGuzzleOptions([
    'http_errors' => false,
    'handler' => HandlerStack::create(new CoroutineHandler())
]);
//重写缓存
$app['cache'] = di()->get(CacheInterface::class);
//获取回调通知
//可以直接修改easywehcat的request 或者直接使用hyperf的 request获取body自行解析xml
//重写easywechat的request
//        $get = $request->getQueryParams();
//
//        $post = $request->getParsedBody();
//
//        $cookie = $request->getCookieParams();
//
//        $files = $request->getUploadedFiles();
//
//        $server = $request->getServerParams();
//
//        $xml = $request->getBody()->getContents();
//
//        $app['request'] = new Request($get, $post, [], $cookie, $files, $server, $xml);

发表评论

0/200
94 点赞
0 评论
收藏
为你推荐 换一批