0

按照以下确切说明: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>

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

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

任何帮助将不胜感激。

4

1 回答 1

0

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

于 2012-01-05T20:06:37.167 回答