0

我在制作对话框以要求用户登录我的 Facebook 标签以参加比赛时遇到问题。

我们正在尝试使用带有以下代码的 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
      });

当我们包含 redirect_uri 时,我们会收到以下消息

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我们会收到以下消息。

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.
4

4 回答 4

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();
                }
            });
        }
    });
于 2011-09-30T20:02:17.450 回答
1

原来有一些问题,在我的应用程序设置中,我必须选择“网站”并输入我网站的 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>
于 2011-10-02T00:14:50.500 回答
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");
}
});
}
}
)
于 2011-10-01T07:00:12.847 回答
0

确保您发出的请求与您在 facebook api 中注册的请求来自同一个域

于 2011-10-01T05:31:05.117 回答