good afternoon,
I have been trying to use “login with facebook” on my website for 15 days. I have been using the code published by Facebook
My problem with this code is that I want the customer after login with his facebook (through the window that pop out) to be redirected to a specific page on my website, but what happens is that after the customer does login with your facebook, the client is redirected to the same page that asks him to login.
I have already followed the steps that are explained in the link that I mentioned earlier. Could someone help me? Thanks
The code i am using is this:
- <fb:login-button scope=“public_profile,email” onlogin=“checkLoginState();”> </fb:login-button>
- </script> <html> <head> <title>Facebook Login JavaScript Example</title> <meta charset="UTF-8"> </head> <body> <script>
- function statusChangeCallback(response) {
- console.log('statusChangeCallback');
- console.log(response);
- if (response.status === 'connected') {
- testAPI();
- } else {
- document.getElementById('status').innerHTML = 'Please log ' +
- 'into this webpage.';
- }
- }
- function checkLoginState() {
- FB.getLoginStatus(function(response) {
- statusChangeCallback(response);
- });
- }
- window.fbAsyncInit = function() {
- FB.init({
- appId : '{xxxxxxxxxxxx}',
- cookie : true,
- xfbml : true,
- version : '{api-version}'
- });
- FB.getLoginStatus(function(response) {
- statusChangeCallback(response);
- });
- };
- (function(d, s, id) {
- var js, fjs = d.getElementsByTagName(s)[0];
- if (d.getElementById(id)) return;
- js = d.createElement(s); js.id = id;
- js.src = "https://connect.facebook.net/en_US/sdk.js";
- fjs.parentNode.insertBefore(js, fjs);
- }(document, 'script', 'facebook-jssdk'));
- function testAPI() {
- console.log('Welcome! Fetching your information.... ');
- FB.api('/me', function(response) {
- console.log('Successful login for: ' + response.name);
- document.getElementById('status').innerHTML =
- 'Thanks for logging in, ' + response.name + '!';
- });
- }
- </script> <fb:login-button scope="public_profile,email" onlogin="checkLoginState();"> </fb:login-button> <div id="status"> </div> </body> </html> <div id="fb-root"></div> <script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v6.0&appId=xxxxxxxxx&autoLogAppEvents=1"></script> <div class="fb-login-button" data-width="" data-size="" data-button-type="continue_with" data-layout="rounded" data-auto-logout-link="true" data-use-continue-as="true"></div> <script>