Laravel 5.4 - Socialite Providers 与 Twitter 的多种配置
Laravel 5.4 - Socialite Providers multiple configurations with Twitter
我有两个服务可以连接到 Socialite Provider:
use Laravel\Socialite\Facades\Socialite;
use \SocialiteProviders\Manager\Config;
public function connect_1() {
$config1 = new Config(
env('TWITTER_CONSUMER_KEY_1'),
env('TWITTER_CONSUMER_SECRET_1'),
env('TWITTER_REDIRECT_URI_1'),
[
//
]
);
return Socialite::with('twitter')->setConfig($config1)->redirect();
}
public function connect_2() {
$config2 = new Config(
env('TWITTER_CONSUMER_KEY_2'),
env('TWITTER_CONSUMER_SECRET_2'),
env('TWITTER_REDIRECT_URI_2'),
[
//
]
);
return Socialite::with('twitter')->setConfig($config2)->redirect();
}
但是,当我尝试此代码时出现此错误:
Configuration for TWITTER_KEY is missing. There is no services entry
for twitter
我认为这会在之后起作用
https://packagist.org/packages/socialiteproviders/manager
$clientId = "secret";
$clientSecret = "secret";
$redirectUrl = "yourdomain.com/api/redirect";
$additionalProviderConfig = ['site' => 'meta.whosebug.com'];
$config = new \SocialiteProviders\Manager\Config($clientId, $clientSecret, $redirectUrl, $additionalProviderConfig);
return Socialite::with('provider-name')->setConfig($config)->redirect();
我有两个服务可以连接到 Socialite Provider:
use Laravel\Socialite\Facades\Socialite;
use \SocialiteProviders\Manager\Config;
public function connect_1() {
$config1 = new Config(
env('TWITTER_CONSUMER_KEY_1'),
env('TWITTER_CONSUMER_SECRET_1'),
env('TWITTER_REDIRECT_URI_1'),
[
//
]
);
return Socialite::with('twitter')->setConfig($config1)->redirect();
}
public function connect_2() {
$config2 = new Config(
env('TWITTER_CONSUMER_KEY_2'),
env('TWITTER_CONSUMER_SECRET_2'),
env('TWITTER_REDIRECT_URI_2'),
[
//
]
);
return Socialite::with('twitter')->setConfig($config2)->redirect();
}
但是,当我尝试此代码时出现此错误:
Configuration for TWITTER_KEY is missing. There is no services entry for twitter
我认为这会在之后起作用 https://packagist.org/packages/socialiteproviders/manager
$clientId = "secret";
$clientSecret = "secret";
$redirectUrl = "yourdomain.com/api/redirect";
$additionalProviderConfig = ['site' => 'meta.whosebug.com'];
$config = new \SocialiteProviders\Manager\Config($clientId, $clientSecret, $redirectUrl, $additionalProviderConfig);
return Socialite::with('provider-name')->setConfig($config)->redirect();