duancongduo4109 2013-07-11 09:28
浏览 22
已采纳

Javascript fb.Login,error不允许给定URL

This my code:

   <div id="fb-root"></div>
   <body>
   <script>
            window.fbAsyncInit = function() {
                FB.init(
                {
                    appId: 'XXX',
                    status: true,
                    cookie: true,
                    xfbml: true,
        channelUrl: 'fbsite.url'

                });
            };

            (function() {
                var e = document.createElement('script');
                e.src = document.location.protocol + '//connect.facebook.net/en_US  /all.js';
                e.async = true;
                document.getElementById('fb-root').appendChild(e);
            }());
        //LOGIN FUNCTION 
   function login() {
    FB.login(function(response) {
        if (response.authResponse) {
            alert('Success!');
        }else{
            alert('Login Failed!');
        }
    }, {scope: 'email'});
 }

  </script>
  <div onclick="login();">Login with Facebook</div>

If I click Login with Facebook on div, that I get error, is this :

Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.

Why is that?

  • 写回答

1条回答 默认 最新

  • dtz46697 2013-07-11 13:07
    关注

    Issue may be with the callback url. Check your website url and call back url which you have provided while creating your facebook application. Both of them should be same or subdomain (base domain should be same). If you are calling fb login from localhost, provide the callback url also as localhost/....

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序