Facebook opengraph表单错误

时间:2012-03-31 03:21:52

标签: facebook facebook-graph-api opengraph facebook-opengraph

我正在尝试facebook opengraph cookie食谱教程,我正在遵循所有说明,但每次我点击厨师表格时,它仍然会说错误。我正在使用php并使用heroku服务器。这是我的代码:

<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# tommytechcook: 
              http://ogp.me/ns/apps/tommytechcook#">
<title>OG Tutorial App</title>
<meta property="fb:app_id" content="145722645553824" /> 
<meta property="og:type" content="tommytechcook:recipe" /> 
<meta property="og:title" content="Stuffed Cookies" /> 
<meta property="og:image" content="http://fbwerks.com:8000/zhen/cookie.jpg" /> 
<meta property="og:description" content="The Turducken of Cookies" /> 
<meta property="og:url" content="https://simple-journey-2635.herokuapp.com/cook.html">

<script type="text/javascript">
function postCook()
{
  FB.api(
    '/me/tommytechcook:cook?recipe=https://simple-journey-2635.herokuapp.com/cook.html',
    'post',
    function(response) {
       if (!response || response.error) {
          alert('Error occured');
       } else {
          alert('Cook was successful! Action ID: ' + response.id);
       }
    });
}
</script>
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
  FB.init({
    appId      : '145722645553824', // App ID
    status     : true, // check login status
    cookie     : true, // enable cookies to allow the server to access the session
    xfbml      : true  // parse XFBML
  });
};

// Load the SDK Asynchronously
(function(d){
  var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
  js = d.createElement('script'); js.id = id; js.async = true;
  js.src = "//connect.facebook.net/en_US/all.js";
  d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>

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

<h3>Stuffed Cookies</h3>
<p>
<img title="Stuffed Cookies" 
     src="http://fbwerks.com:8000/zhen/cookie.jpg" 
     width="550"/>
</p>

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

2 个答案:

答案 0 :(得分:1)

alert(response.error); 

将返回“Object Object”。

改为使用:

alert(JSON.stringify(response.error));

user1304503,我很想知道你是如何解决这个问题的 - 我很难自己设置一个测试应用程序(一个发布到用户新闻源的应用程序)

WoolyG

答案 1 :(得分:0)

我的猜测是你没有登录。我没有在任何地方看到FB.login()。

错误信息是什么?
alert('Error occured');更改为alert(response.error);以查看错误消息。