微信公众号授权
public function gzhlogo(){
$config= [
'app_id' => '',
'secret' => ''
];
$app = Factory::officialAccount($config);
$response = $app->oauth->scopes(['snsapi_userinfo'])->redirect('回调到下面的方法定义好路由');
return $response->send(); ;
}
public function gzhlogos(){
$config= [
'app_id' => '',
'secret' => ''
];
$app = Factory::officialAccount($config);
$oauth = $app->oauth;
// 获取 OAuth 授权结果用户信息
$user = $oauth->user();
$users = DB::name('gzh')->where('text',$user->getId())->find();
if (empty($users)) {
DB::name('gzh')->insertGetId(['text' => $user->getId()]);
}
echo "<h1>OPENID:".$user->getId()."</h1>";
}
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果