php - 在laravel中 用easywechat 做网页授权 如何在测试环境获取生产环境中的openid 这个callback处怎么搞
本文介绍了php - 在laravel中 用easywechat 做网页授权 如何在测试环境获取生产环境中的openid 这个callback处怎么搞的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
public function handle($request, Closure $next)
{
$wechat = config('wechat');
$app = new Application([
'debug' => false,
'app_id' => $wechat['app_id'],
'secret' => $wechat['secret'],
'token' => $wechat['token'],
'log' => [
'level' => 'debug',
'file' => storage_path('logs/log.log'),
],
'oauth' => [
'scopes' =>['snsapi_base'],
'callback' => '/callback',
]
]);
$oauth = $app->oauth;
if (env('APP_ENV') == 'local'){
session(['openid_user' => 'test']);
}
$openid = session('openid_user');
if (empty($openid)){
return $oauth->redirect();
}
解决方案
知道怎么弄了
public function handle($request, Closure $next)
{
$wechat = config('wechat');
$app = new Application([
'debug' => false,
'app_id' => $wechat['app_id'],
'secret' => $wechat['secret'],
'token' => $wechat['token'],
'log' => [
'level' => 'debug',
'file' => storage_path('logs/log.log'),
],
'oauth' => [
'scopes' =>['snsapi_base'],
'callback' => '填带http的完整域名地址',
]
]);
$oauth = $app->oauth;
if (env('APP_ENV') == 'local'){
session(['openid_user' => 'test']);
}
$openid = session('openid_user');
if (empty($openid)){
return $oauth->redirect();
}
这篇关于php - 在laravel中 用easywechat 做网页授权 如何在测试环境获取生产环境中的openid 这个callback处怎么搞的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文