对文档的代码调整了下,但没办法打印sendl输出内容,难道要采用ob?
<?php
namespace app\controller;
use support\Request;
use EasyWeChat\Factory;
use Symfony\Component\HttpFoundation\HeaderBag;
use Symfony\Component\HttpFoundation\Request as SymfonyRequest;
use app\BaseController;
class Wechat extends BaseController
{
public function index(Request $request)
{
$config = [
'app_id' => '',
'secret' => '',
'token' => '',
'response_type' => 'array',
];
$app = Factory::officialAccount($config);
$symfony_request = new SymfonyRequest($request->get(), $request->post(), [], $request->cookie(), [], [], $request->rawBody());
$symfony_request->headers = new HeaderBag($request->header());
$app->rebind('request', $symfony_request);
$app->server->push(function ($message) {
return "您好!欢迎关注";
});
$response = $app->server->serve();
return $response->send()->getContent();
}
}
我做过这个,我记得不是ob,晚上找一下项目
return xml($response->getContent());
目前是这样写的,解决是解决了,但wechat不熟,慢慢研究
mark
这样可以吗....找个时间试试,3Q