i new in facebook app. everything's fine until now, when click fb login button. ask me permission redirect me actions.php. now, redirect me ssl url outside facebook canvas. see plain web page not in facebok page anymore.
here's index code , action.php displays home page:
index.php
<?php error_reporting(0); include 'library.php'; ?> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>help</title> <script type="text/javascript"> window.fbasyncinit = function() { fb.init({ appid : '*************', // replace app id here channelurl : '//<domain_name>/bacardi-test/channel.html', status : true, cookie : true, xfbml : true }); }; (function(d){ var js, id = 'facebook-jssdk', ref = d.getelementsbytagname('script')[0]; if (d.getelementbyid(id)) {return;} js = d.createelement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/en_us/all.js"; ref.parentnode.insertbefore(js, ref); }(document)); function fblogin(){ fb.login(function(response){ if(response.authresponse){ window.top.location = "actions.php?action=fblogin"; } }, {scope: 'email,user_likes,user_birthday'}); } </script> </head> <body> <div id="fb-root"></div> <img src="assets/img/bacardi/facebook-connect.png" alt="fb connect" title="login facebook" onclick="fblogin();"/> </body> </html> actions.php <?php include 'library.php'; $action = $_request["action"]; switch($action){ case "fblogin": include 'src/facebook.php'; $appid = "**************"; $appsecret = "************"; $facebook = new facebook(array( 'appid' => $appid, 'secret' => $appsecret, 'cookie' => true, )); $fbuser = $facebook->getuser(); if ($fbuser) { try { $user_profile = $facebook->api('/me'); } catch (exception $e) { echo $e->getmessage(); exit(); } # account id $user_fbid = $fbuser; # account bday $user_bday = $user_profile['user_birthday']; # account email $user_email = $user_profile['email']; # account firstname $user_fname = $user_profile['first_name']; # account lastname $user_lname = $user_profile['last_name']; # accounr image url $user_image = "https://graph.facebook.com/".$user_fbid."/picture?type=large"; $check_select = mysql_num_rows(mysql_query("select * `users` email = '$user_email'")); if($check_select == 0){ mysql_query("insert `users` (fb_id, fname,lname, email, image, birthday,postdate) values ('$user_fbid', '$user_fname', '$user_lname', '$user_email', '$user_image', '$user_bday',now())"); } } break; } ?>
it seems window.top.location broke iframe of facebook. working on automatic prompt of permission rather button somehow change it. it's working. changed window.top.location window.location.href. everyone's time reading prob.