2011-02-25 125 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