I am getting problem to redirect page after website login with facebook.
1. On click of facebook login button from site it redirect to facebook login page
2. User get authenticate but it is not redirecting to next page given in headrer('');
3. If i refresh same page then it redirect to given location and url is looking like =">http://192.1.1.1/mysite/welcome.php/#=
4. It is working properly for google.com but not for local url and google url is looking like incorrect google url My code
if(isset($_GET['fb'])) { $token_url = "https://graph.facebook.com/oauth/access_token?"."client_id=".$config['App_ID']."&redirect_uri=".urlencode($config['callback_url'])."&client_secret=".$config['App_Secret']."&code=".$_GET['code']; $response = file_get_contents($token_url); $params = null; parse_str($response, $params); $graph_url = "https://graph.facebook.com/me?access_token=".$params['access_token']; $user = json_decode(file_get_contents($graph_url)); //user data from facebook $email = $user->{'email'}; //i am getting email id from json data //search out for entry available for email in database $val_user = "SELECT email FROM tbl_facebook WHERE email ='".$email."'"; $res_val_user = $con->query($val_user); $count = mysqli_num_rows($res_val_user); // if not then insert data to database if($count==0) { $ins_fb = "INSERT INTO tbl_facebook set email='".$email."'"; $res_fb = mysqli_query($con,$ins_fb); if($res_fb) { //echo "facebook data saved"; exit; //working for this //header('Location:https://www.google.co.in/'); //working for this also header('Location:http://192.1.1.1/mysite/welcome.php'); } else { echo "facebook data is not saved"; } } else // if yes then redirect to welcome page { //echo "login successfully"; exit; // working for this also header('Location:http://192.1.1.1/mysite/welcome.php'); // getting problem to redirect //header('Location:https://www.google.co.in/'); } }
<?php // code for facebook login require 'lib/facebook/src/config.php'; require 'lib/facebook/src/facebook.php'; // Create our Application instance (replace this with your appId and secret). $facebook = new Facebook(array( 'appId' => $config['App_ID'], 'secret' => $config['App_Secret'], 'cookie' => true )); ?>
<a class="btn-facebook" href="https://www.facebook.com/dialog/oauth?client_id=<?php echo $config['App_ID']?>&redirect_uri=<?php echo $config['callback_url']?>&scope=email,user_likes,publish_stream"> <i class="icon-facebook icon-large"></i> Signin with Facebook </a>