2013-08-23 3 views
0

저는 facebook 앱에서 새로운입니다. fb 로그인 버튼을 클릭하면 지금까지는 문제가 없습니다. 일반적으로 권한을 요청한 후 나를 actions.php로 리디렉션합니다. 이제는 페이스 북 캔버스 외부의 SSL URL로 리디렉션됩니다. 그래서 지금 내가 보는 것은 평범한 웹 페이지가 facebok 페이지에 더 이상 없다는 것입니다. window.top.location가 페이스 북의 iframe이 파산 것 같다fblogin 버튼을 클릭하면 SSL URL에 Facebook 앱이 열립니다.

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 your 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 with 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 * FROM `users` WHERE email = '$user_email'")); 
     if($check_select == 0){ 
      mysql_query("INSERT INTO `users` (fb_id, fname,lname, email, image, birthday,postdate) 
      VALUES ('$user_fbid', '$user_fname', '$user_lname', '$user_email', '$user_image', '$user_bday',now())"); 
     } 
    } 
    break; 
    } 

?> 

답변

0

:

여기 내 홈 페이지를 표시합니다 내 인덱스 코드 내 action.php입니다. 나는 어떻게 든 버튼을 으로 변경하는 대신에 권한의 자동 프롬프트로 작업하고있었습니다. 이제 이미 작동 중입니다. 방금 window.top.location을 window.location.href로 변경했습니다. 모두의 시간을 내 주셔서 감사합니다.

관련 문제