<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
laravel-socialite-providers / socialite-wechat-web example snippets
/**
* The event handler mappings for the application.
*
* @var array
*/
protected $listen = [
\SocialiteProviders\Manager\SocialiteWasCalled::class => [
// add your listeners (aka providers) here
'LaravelSocialiteProviders\\WeChatWeb\\WeChatWebExtendSocialite@handle',
],
];
'wechat_web' => [
'client_id' => env('WECHAT_WEB_APP_ID'),
'client_secret' => env('WECHAT_WEB_APP_SECRET'),
'redirect' => env('WECHAT_WEB_CALLBACK_URL'),
'scopes' => preg_split('/,/', env('WECHAT_WEB_SCOPES'), null, PREG_SPLIT_NO_EMPTY), // can not use explode, see vlucas/phpdotenv#175
'union_id_with' => preg_split('/,/', env('WECHAT_WEB_UNION_ID_WITH'), null, PREG_SPLIT_NO_EMPTY),
],
return Socialite::with('wechat_web')->redirect();
// to turn off stateless
return Socialite::with('wechat_web')->stateless(false)->redirect();
// to use stateless
return Socialite::with('wechat_web')->stateless()->redirect();
// default use openid as $user->id
$user = Socialite::driver('wechat_web')->user();
$accessTokenResponseBody = $user->accessTokenResponseBody;
// use unionid as $user->id
$user = Socialite::driver('wechat_web')->scopes('unionid')->user();