【问题标题】:Unable to publish sample open graph as per instructions无法按照说明发布示例打开图
【发布时间】:2012-02-03 11:56:36
【问题描述】:

严格按照以下说明进行操作: http://developers.facebook.com/docs/beta/opengraph/tutorial/#publish

并且收到“发生错误”错误

会发生什么?代码如下:

================================================ =================

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"
xmlns:fb="https://www.facebook.com/2008/fbml"> 

<head prefix="og: http://ogp.me/ns# test_app: 
http://ogp.me/ns/apps/test_app#"> 
<meta property="fb:app_id" content="129xxxxxxxxxxxx" /> 
<meta property="og:type" content="test_app:recipe" /> 
<meta property="og:title" content="Stuffed Cookies" /> 
<meta property="og:image" content="http://x.example.com/cookedrcp.jpg" /> 
<meta property="og:description" content="The Turducken of Cookies" /> 
<meta property="og:url" content="http://apps.facebook.com/test_app/index.php"> 

<script type="text/javascript">
function postCook()
{
    FB.api('/me/test_app:cook' + 
                '?recipe=http://apps.facebook.com/test_app/index.php','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:'129xxxxxxxxxxxx', 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://x.example.com/cookedrcp.jpg" 
                        width="550"/><br />
    </p>       

    <form>
        <input type="button" value="Cook" onclick="postCook()" />
    </form>
</body> 
</html>

================================================ =======================

我已经根据示例页面创建了开放图,例如烹饪食谱。

任何帮助将不胜感激。

【问题讨论】:

  • 您是否遇到任何 javascript 错误?您是否尝试过使用Facebook Debugger Tool 来查看 facebook 如何查看您的 URL?
  • 你的response.error是什么?

标签: facebook-opengraph open-graph-beta


【解决方案1】:

我感觉您没有为用户获得有效的 access_token。在文档(https://developers.facebook.com/docs/beta/opengraph/tutorial/#publish)中,它说您的用户需要已经通过您的应用程序的身份验证。在调用 FB.api() 之前,通过调用 FB.getLoginStatus() 确保当前用户已通过身份验证。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-11
    • 2011-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多