php - redirect after authentification facebook sdk -
I am working on a website and using Facebook API
Here my code Is:
& lt ;? Php session_start (); // v4.0.0 Added_ need_once ('Facebook / FacebookSession.php'); Need_once ('Facebook / FacebookRedirectLoginHelper.php'); Need_once ('facebook / facebook request.php'); Need_once ('facebook / facebookResponse.php'); Need_once ('facebook / facebooksdkexception.php'); Require_once ('Facebook / FacebookRequestException.php'); Need_once ('facebook / facebookAuthorizationException.php'); Need_once ('facebook / graphObject.php'); Require_once ('Facebook / HttpClients / FacebookCurl.php'); Require_once ('Facebook / HttpClients / FacebookHttpable.php'); Require_once ('Facebook / HttpClients / FacebookCurlHttpClient.php'); Need_once ('facebook / entities / accesstoken.php'); Need_once ('facebook / graphUser.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; // Start Session // App ID and App app with secret FacebookSession :: setDefaultApplication ('APP_ID', 'APP-SECRET'); // redirect_uri $ accessory with login assistant = new FacebookRedirectLoginHelper ('http://www.immomix.ma/mysdk/src/begin.php'); Try {$ Session = $ helper->; GetSessionFromRedirect (); } Hold (FacebookRequestException $ ex) {// When Facebook returns an error} Grab (Exception $ east) {// when verification fails or other local issues} echo & lt; A href = "'. $ Helper- gt; getLoginUrl (array (' scope '=>' email ')).' '& Gt; Login & lt; / a & gt;';
Verification is going on completely but the problem is that I would like to go to another link after this verification, because after verification, my following code comes back to this link. / P>
I How to change it to someone else.
/ / try this & Lt ;? php session_start (); // contains the included file and $ app_id = 'xxx' T; $ App_secret = 'xxx'; FacebookSession :: setDefaultApplication ($ app_id, $ app_secret); $ Assistant = new FacebookRedirectLoginHelper ( "` the same page URL here / '); Try {$ Session = $ helper->; GetSessionFromRedirect (); } Hold (FacebookRequestException $ ex) {} hold (exception $ east) {} $ loggedIn = false; If (Asset ($ session)) {if ($ session) {// session after login login $ log = true; {// Log // // $ user_profile = (Try to bring under the new FacebookRequest ($ session, 'GET', '/ me')) - & gt; Execute () - & gt; GetGraphObject (GraphUser :: className ()); Print_r ($ user_profile); // print data} hold (FacebookRequestException $ e) {echo "exception occurred, code:". $ E & gt; GetCode (); Echo "with message": "$ E" getMessage ();}}} if (! $ LoggedIn) // if the user is not online // Get link and add scope {$ loginUrl = $ helper- & Gt; getLoginUrl (arrays ('public_profile', 'email')); next "& lt; A href = '$ loginUrl' & gt; Login with Facebook & lt; / A & gt; ";} Other {print_r ($ user_profile); // logout link is generated here & lt; br & gt; & lt; br & gt; & lt; a href =" index.php " & gt; logout & lt; / a & gt; '; // sceen} to print? & Gt;
Comments
Post a Comment