I would like to have two login buttons on my page. I'm not too familier with the coding of the SDK, is this possible?
One button works fine, but the second button doesn't. It just changes the url to index.php?code=wKdOAOLK... without logging in.
Any workaround?
code:
// added in v4.0.0
require './facebook-sdk/autoload.php';
use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\Entities\AccessToken;
use Facebook\HttpClients\FacebookCurlHttpClient;
use Facebook\HttpClients\FacebookHttpable;
use Facebook\GraphUser;
// start session
// init app with app id and secret
FacebookSession::setDefaultApplication( 'x','x' );
// login helper with redirect_uri
$helper = new FacebookRedirectLoginHelper('http://localhost/' );
try {
$session = $helper->getSessionFromRedirect();
} catch( FacebookRequestException $ex ) {
// When Facebook returns an error
} catch( Exception $ex ) {
// When validation fails or other local issues
}
// see if we have a session
if ( isset( $session ) ) {
...
}
Buttons, both the same code:
<?php echo '<a href="' . $helper->getLoginUrl() . '"><img src="facebook.png"></a>'; ?>
<?php echo '<a href="' . $helper->getLoginUrl() . '"><img src="facebook.png"></a>'; ?>
Aucun commentaire:
Enregistrer un commentaire