在用户时间轴上发布操作时出现问题

时间:2012-03-04 16:27:44

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

我已经按照这些教程进行了操作:

http://onlytipsandtricks.com/facebook/facebook-application-development-with-open-graph/

然后:

http://onlytipsandtricks.com/facebook/how-to-publish-actions-on-timeline/

但是当我尝试发布我总是得到的动作时:

消息:(#3502)URL xxxxxx处的对象具有og:'website'的类型属性'article'需要og的对象:type'mynamespacexxxx:article'。

我的源代码:

<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# fb: http://ogp.me/ns/fb# xxxxxxxxx: http://ogp.me/ns/fb/xxxxxxxxxx#">
  <meta property="fb:app_id"      content="xxxxxxxxxxxxxx" /> 
  <meta property="og:type"        content="xxxxxxxxxxx:article" /> 
  <meta property="og:url"         content="http://xxxxxxxxxxxxx/timeline/redir.php" /> 
  <meta property="og:title"       content="Sample Article" /> 
  <meta property="og:description" content="Some Arbitrary String" /> 
  <meta property="og:image"       content="http://ogp.me/logo.png" /> 


<script type="text/javascript">
function read()
{
FB.api('/me/xxxxxxxxxxx:read' + 
'?article=http://xxxxxxxxxxxxx/timeline/redir.php&access_token=','post',
function(response) {
var msg = 'Error occured';
if (!response || response.error) {
if (response.error) {
msg += "\n\nType: "+response.error.type+"\n\nMessage: "+response.error.message;
}
alert(msg);
} 
else {
alert('Post was successful! Action ID: ' + response.id);
}
});
}
</script>

<style type="text/css">
<!--
.style1 {
    font-family: Georgia, "Times New Roman", Times, serif;
    color: #0066CC;
    font-size: 24px;
}
-->
</style>
</head> 

<body>
<span class="style1">This is Open Graph test page Click on <strong>Post To your Timeline</strong> button to test.</span>
<fb:add-to-timeline></fb:add-to-timeline>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>

<script>
FB.init({ 
appId:'xxxxxxxxxxxxx', cookie:true, 
status:true, xfbml:true, oauth:true
});
</script>
<form>
<input type="button" value="Post To Your Timline " onClick="read()" />
</form>
</body> 
</html>

2 个答案:

答案 0 :(得分:1)

尝试debugger,看看Facebook看到的确切内容,并更新Facebook的缓存。

答案 1 :(得分:1)

当我的应用程序试图在我的时间轴上发布一个opengraph对象时,我遇到了这个问题。

在我的情况下,原因是服务器端重定向到我试图发布的对象的facebook画布页面。因为对象页面是在facebook上的iFrame中呈现的,所以它是og:type不可见,而且是facebook页面的og:返回的类型。

我通过为我的对象创建一个最小页面模板解决了这个问题,该模板只包含opengraph内容和javascript重定向到实际对象页面。