0
My code in Composer.json looks like this
{
"name": "testesocial/vinicius",
"description": "Login com facebook",
"type": "project",
"minimum-stability": "stable",
"autoload": {
"psr-4": {
"Source\\": "testeoauth/"
},
"files": [
"source/Config.php"
]
},
"require": {
"league/oauth2-facebook": "^2.0.*"
}
}
my source->config.php looks like this:
define("FACEBOOK", [
"app_id" => "",
"app_secret" => "",
"app_redirect" => "https://www.localhost/testeoauth/",
"app_version" => "v4.0"
]);
I’d like to leave this file with the FACEBOOK array on autolood, but it’s not getting, so I’m having to give require always, so:
<?php
ob_start();
require "vendor/autoload.php";
// require "source/Config.php";
if(empty($_SESSION["userLogin"])) {
echo "<h1>Guest</h1>";
$facebook = new \League\OAuth2\Client\Provider\Facebook([
'clientId' => FACEBOOK["app_id"],
'clientSecret' => FACEBOOK["app_secret"],
'redirectUri' => FACEBOOK["app_redirect"],
'graphApiVersion' => FACEBOOK["app_version"]
]);
$authUrl = $facebook->getAuthorizationUrl([
"scope" => ["email"]
]);
echo "<a title='FB Login' href='{$authUrl}'>Facebook Login</a>";
} else {
echo "<h1>User Name</h1>";
}
ob_end_flush();
I wish I didn’t have to give the required
require "vendor/autoload.php";
if that line is spoken ???– novic
No, the line that is commented to "require "source/Config.php" Without it my code breaks.
– sahusa
I need to know then the set of folders, if you have the github of it?
– novic
Got no, I got his zip.
– sahusa
it might work but, not the way you did, and another need to put in the packgist that there in the package manager
– novic
Here is the link to github: https://github.com/sahusa/testeoauth
– sahusa
Boy is the other link! if you’re half lost.
– novic
I sent you the link to my project’s github repository
– sahusa
In the Github repository you only have the Composer files and the
index.php
, missing the rest. Review the names of the files and folders, it may be a typo– Costamilam
But the project really only contains these files currently, I’m just testing the use of Composer, already managed to find the solution, grateful.
– sahusa