【问题标题】:Facebook App User Authentication using Java Script SDK: Given URL is not Allowed使用 Java Script SDK 的 Facebook 应用用户身份验证:不允许给定 URL
【发布时间】:2012-02-08 08:03:48
【问题描述】:

我正在尝试实施 Recipe Box Facebook 应用教程的第二步。我已按照第一步中的说明在 Facebook 上设置我的应用程序,并按照教程第二步中的说明将下面粘贴的代码上传到我的服务器。当我加载网页并单击添加到时间线链接时,我收到一条 Facebook 错误消息:

Given URL is not allowed by the Application configuration.

任何见解将不胜感激。

代码:

 <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
     xmlns:fb="https://www.facebook.com/2008/fbml"> 
 <head>
<head/> 
<body> 
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
    FB.init({ 
        appId:'328617653826422', cookie:true, 
        status:true, xfbml:true, oauth:true
    });
</script>

<fb:add-to-timeline></fb:add-to-timeline>

<h3>
    <font size="30" face="verdana" color="grey">
        Stuffed Cookies
    </font> 
</h3> 
<p>
    <img title="Stuffed Cookies" 
            src="http://example.com/cookie.jpg" 
            width="550"/>
</p>       
</body> 
</html>

【问题讨论】:

    标签: facebook facebook-javascript-sdk facebook-apps facebook-authentication


    【解决方案1】:

    在您的应用设置中,确保您指定的域与此代码所在的域相同。同样在示例代码中,他们的&lt;head&gt; 标签看起来像&lt;head prefix="og: http://ogp.me/ns# og_recipebox: http://ogp.me/ns/apps/YOUR_NAMESPACEx#"&gt;。此外,您似乎也缺少头部部分中的 og: 标签。

    这是我刚刚从他们的网站下载的示例代码,我是否抓取了错误的链接?还是您基于旧的示例代码?

    <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"> 
    
    <head prefix="og: http://ogp.me/ns# og_recipebox: http://ogp.me/ns/apps/YOUR_NAMESPACEx#"> 
        <meta property="fb:app_id" content="YOUR_APP_ID" /> 
        <meta property="og:type" content="YOUR_NAMESPACE:recipe" /> 
        <meta property="og:title" content="Oreo Stuffed Cookies" /> 
        <meta property="og:image" content="http://YOUR_URL/cookie.jpg" /> 
        <meta property="og:description" content="The Turducken of Cookies" /> 
        <meta property="og:url" content="http://YOUR_URL/cookie.html"> 
    
        <script type="text/javascript">
        function postCook()
        {
            FB.api('/me/YOUR_NAMESPACE:cook&recipe=http://YOUR_URL/cookie.html','post',  function(response) {
                if (!response || response.error) {
                    alert('Error occured');
                  } else {
                    alert('Post was successful! Action ID: ' + response.id);
                  }
            });
        }
        </script>
    </head> 
    
    <body> 
        <div id="fb-root"></div>
        <script src="http://connect.facebook.net/en_US/all.js"></script>
        <script>
            FB.init({ 
                appId:'YOUR_APP_ID', cookie:true, 
                        status:true, xfbml:true, oauth:true
            });
            </script>
            <fb:add-to-timeline></fb:add-to-timeline>>
            <h3>
                <font size="30" face="verdana" color="grey">Stuffed Cookies
                </font> 
            </h3> 
            <p>
                <img title="Oreo Stuffed Cookies" src="http://YOUR_URL/cookie.jpg" width="550"/><br />
            </p>       
    
            <form>
                <input type="button" value="Cook" onclick="postCook()" />
            </form>
    
            <fb:activity actions="YOUR_NAMESPACE:cook"></fb:activity>
        </body> 
    </html>
    

    【讨论】:

    • 您发布的代码来自本教程的第 4 阶段,我发布的代码来自第 2 阶段,您只是在尝试对用户进行身份验证。无论如何,你是绝对正确的,一旦我修复了它的工作原理,应用程序 Facebook 设置中的域名就出现了拼写错误。非常感谢!
    猜你喜欢
    • 2012-10-02
    • 2014-02-19
    • 1970-01-01
    • 1970-01-01
    • 2012-03-09
    • 2021-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多