2011-02-25 132 views
0

我写了下面的代码来验证Facebook应用程序,但它没有解决许多日子,而不是谷歌。 问题是应用程序第一次访问时,用户提示应用程序验证对话框。当用户允许应用程序不断闪烁的网址。既不显示对话框也不显示应用关闭浏览器后,它运行良好。请你能找出问题所在。我会非常感激。Facebook应用程序认证问题

代码:

$canvas_page = "---my canvas url----"; //i removed actual url here! 
// Create our Application instance (replace this with your appId and secret). 
    $auth_url = "http://www.facebook.com/dialog/oauth?client_id=" 
      . $app_id . "&redirect_uri=" . urlencode($canvas_page) ."&scope=email,read_stream"; 
    $signed_request = $_REQUEST["signed_request"]; 

    list($encoded_sig, $payload) = explode('.', $signed_request, 2); 

    $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true); 

    if (!empty($data["user_id"])) { 
     echo 'Hello: '.$data["user_id"]; 
    }else{ 
     echo "What is the hell"; 
      echo("<script> location.href='" . $auth_url . "'</script>"); 
    } 

回答

2

它应该工作

$canvas_page = "---my canvas url----"; //i removed actual url here! // Create our Application instance (replace this with your appId and secret). $auth_url = "http://www.facebook.com/dialog/oauth?client_id="    . $app_id . "&redirect_uri=" . urlencode($canvas_page) ."&scope=email,read_stream";  $signed_request = $_REQUEST["signed_request"];  list($encoded_sig, $payload) = explode('.', $signed_request, 2);  $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);  if (!empty($data["user_id"])) {   echo 'Hello: '.$data["user_id"];  }else{   echo "What is the hell";   echo("<script> location.href='" . $auth_url . "'</script>");  } 
1

使用:

echo("<script> top.location.href='" . $auth_url . "'</script>"); 

随着top

+0

是否有意义? – 2011-02-26 19:30:52

+1

@Xcoder:什么?! – ifaour 2011-02-26 19:52:55