无法按照说明发布示例打开图表

时间:2012-01-05 16:43:59

标签: facebook-opengraph open-graph-protocol open-graph-beta

遵循以下确切说明: 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>

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

我已根据示例页面创建了开放图表,例如煮一个食谱。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

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