OS: Linux Ubuntu 20.04
Sage 10
Hi, I’m trying to create my own login form via facebook and google. I am using the SocialConnect library.
Here are my files:
// resources/views/form-register.blade.php
<form action="{{ REGISTER_PAGE }}" method="POST">
<button type="submit" name="provider" value="google">google</button>
<button type="submit" name="provider" value="fb">fb</button>
</form>
And the file where I want to handle the event
// app/View/Composers/Register.php
<?php
namespace App\View\Composers;
use SocialConnect\Auth\Service;
use SocialConnect\HttpClient\Curl;
use SocialConnect\HttpClient\RequestFactory;
use SocialConnect\HttpClient\StreamFactory;
use SocialConnect\Common\HttpStack;
use SocialConnect\Provider\Session\Session;
class Register extends Composer
{
public function __construct()
{
// COMMON
$this->is_logged = false;
$this->error = false;
// GOOGLE API INFO
$this->google_id = '100725804944-o108tp4vdcrellsd0lrfpnl59kdq4j54.apps.googleusercontent.com';
$this->google_secret = 'GlnL98Xxhi9TlYzrUFdX-Yxi';
$this->google_redirect = REGISTER_PAGE;
$this->google_loggin_url = false;
// FACEBOOK
$this->fb_api = '320462216157040';
$this->fb_secret = '879143dacd27e105ed711abd0755e242';
$this->fb_login_url = false;
$this->auth = false;
}
protected static $views = [
'register',
];
public function with()
{
return [
'logged' => $this->is_logged,
'error' => $this->error,
'auth' => $this->SocialAuth(),
];
}
public function SocialAuth(){
if(!isset($_POST['provider'])) {
return false;
}
$httpClient = new Curl();
$httpStack = new HttpStack(
$httpClient,
new RequestFactory(),
new StreamFactory()
);
$collectionFactory = null;
$configureProviders = [
'redirectUri' => REGISTER_PAGE,
'provider' => [
'facebook' => [
'applicationId' => '',
'applicationSecret' => '',
'scope' => ['email'],
'options' => [
'identity.fields' => [
'email',
'picture.width(99999)'
],
],
],
'google' => [
'applicationId' => $this->google_id,
'applicationSecret' => $this->google_secret,
],
],
];
$service = new Service(
$httpStack,
new Session(),
$configureProviders,
$collectionFactory
);
$providerName = $_POST['provider'];
$provider = $service->getProvider($providerName);
write_log($provider->makeAuthUrl());
header('Location: ' . $provider->makeAuthUrl());
exit;
}
}
This class is not complete but i have a problem on this stage. After selecting the login method, the following error appears:
Cannot modify header information - headers already sent by (output started at /home/owline/Local Sites/talenti/app/public/wp-includes/class.wp-scripts.php:237)
I have no idea if it’s my code or sage problem.