2011-09-30 82 views
0

我在創建對話框時要求用戶登錄我的Facebook標籤頁以輸入比賽時出現問題。Facebook FB.ui oauth對話框錯誤

我們試圖用以下代碼使用FB.ui oauth對話框。

FB.ui({ 
     client_id: '12345', 
     method: 'oauth', 
     scope: 'email,user_birthday', 
     response_type: 'token', 
     redirect_uri: "https://mydomain.com/test.php" // Change this to proper address 
     }); 

當我們包括我們得到以下信息

API Error Code: 100 API 
Error Description: Invalid parameter 
Error Message: The "redirect_uri" parameter cannot be used in conjunction 
    with the "next" parameter, which is deprecated. 

我們沒有使用下一個參數雖然任何地方REDIRECT_URI,所以不知道它爲什麼這麼說。

當我們拿走redirect_uri時,我們得到以下消息。

API Error Code: 191 API 
Error Description: The specified URL is not owned by the application 
Error Message: redirect_uri is not owned by the application. 

回答

2

我會使用的FB.login方法,而不是這個給你一個選項卡的應用程序內運行。

在您FB.init:

window.fbAsyncInit = function(){ 
     FB.init({ 
      appId: 'your_app_id', 
      status: true, 
      cookie: true, 
      xfbml: true, 
      oauth: true 
     }); 
     FB.Canvas.setAutoGrow(true); 
    }; 

FB.getLoginStatus(function(response){ 
     if(response.status == 'connected'){ 
      callyourfunctiontoentercompetition(); 
     }else{ 
      FB.login(function(response){ 
       if(response.status == 'connected'){ 
        callyourfunctiontoentercompetition(); 
       }else{ 
        handlethecancelpermissions(); 
       } 
      }); 
     } 
    }); 
0

確保UR決策是從同一個域作爲未來你已經註冊了Facebook API

0

在你沒有一個選項卡中的一個請求需要通過比方法和燙髮等任何一個參數(或範圍當Facebook改變它)

FB.getLoginStatus(function(response){ 
     if(response.status == 'connected'){ 
alert("User connected"); 
     }else{ 
FB.ui({ 
     method: 'oauth', 
     perms: 'email,user_birthday' //change perms to scope when Facebook supports it 
     }, function(response){ 
if(response.session){ 
alert("User connected"); 
}else if(response.installed != '1'){ 
alert("User canceled"); 
} 
}); 
} 
} 
) 
1

原來有幾件事情錯了,我的應用程序設置,我不得不選擇「網站」和p在我的網站的URL中,這允許我添加「應用程序域」並保存它。這清理了191錯誤。有網站沒有檢查您的應用程序域不會保存。之後,它很簡單。

這裏是我使用的代碼。

<script> 
    window.fbAsyncInit = function() { 
    FB.init({ 
    appId : 'YOUR_ID', 
    status : true, // check login status 
    cookie : true, // enable cookies to allow the server to access the session 
    xfbml : true, // parse XFBML 
    channelURL : 'http://www.your_domain.ca/channel.html', // channel.html file 
    oauth : true // enable OAuth 2.0 
    }); 
    // This should be fired on a user initiated action 

    FB.ui({ method: 'oauth', perms: 'email' }, function() { callback() }); 
    }; 
    (function(d){ 
    var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;} 
    js = d.createElement('script'); js.id = id; js.async = true; 
    js.src = "//connect.facebook.net/en_US/all.js"; 
    d.getElementsByTagName('head')[0].appendChild(js); 
    }(document)); 

    function callback() { 

    FB.getLoginStatus(function(response) { 
    if (response.authResponse) { 
    FB.api('/me', function(response) { 
     //Get user information from here 
    }); 
    } 
    }); 
    } 


</script>