当我尝试发布自定义操作时,我收到一个错误(如下(,声称代表我的对象的URL是网站类型。正如你从我的对象html中看到的那样,我包含了a.og:type"{app_namespace}:{object_name}"标记,事实上,这段代码主要是由开发人员应用程序生成的。我过去曾成功发布过其他应用程序的自定义操作,但这次我不知道有什么不同。如有任何建议,我们将不胜感激。
Facebook错误:
{"error":{"message":"(#3502) Object at URL {URL} has og:type of 'website'. The property 'issue' requires an object of og:type '{app_namespace}:{object_name}'. ","type":"OAuthException","code":3502}}
对象Html:
<html>
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# {app_namespace}: http://ogp.me/ns/fb/{app_namespace}#">
<meta property="og:type" content="{app_namespace}:{object_name}" />
<meta property="fb:app_id" content="{app_id}" />
<meta property="og:url" content={URL for this Html} />
<meta property="og:title" content="Sample title" />
<meta property="og:image" content="https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png" />
</head>
<body>
</body>
</html>
我用来发布操作的代码:
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
function clickHandler() {
FB.getLoginStatus(function (response) {
if (response.authResponse) {
FB.api('/me/{app_namespace}:{action_name}?{object_name}={object_url}', 'post', function (response) {
alert(JSON.stringify(response));
});
} else {
//If user not logged in initiate login process
FB.login(function (response) {
if (response.authResponse) {
FB.api('/me/{app_namespace}:{action_name}?{object_name}={object_url}', 'post', function (response) {
alert(JSON.stringify(response));
});
//actionPublish();
} else {
//user cancelled login or did not grant authorization
}
}, {
scope: 'publish_actions'
});
}
});
}
$(document).ready(function () {
window.fbAsyncInit = function () {
FB.init({
appId: '{app_id}',
status: true,
cookie: true,
xfbml: true,
oauth: true
});
// run once with current status and whenever the status changes
FB.getLoginStatus(updateButton);
FB.Event.subscribe('auth.statusChange', updateButton);
};
(function () {
var e = document.createElement('script');
e.async = true;
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
$("#fb-root").append(e);
}());
});
</script>
</head>
<body>
<div id="fb-root"></div>
<button id="publishButton" onclick=clickHandler(); return false " >Publish</button>
</body>
编辑:
如果我将fb对象URL粘贴到调试工具中,我会得到以下错误:
"在URL处提取对象时出错"http://www.thepropagator.com/takeAction/draft_1/demos3/issue_4.php',或通过重定向或'og:url'属性指定的url之一,包括http://www.thepropagator/takeAction/draft_1/demos3/issue_4.php.">
如果我尝试一起屏蔽URL标签,错误就会消失,无论在哪种情况下,当我尝试发布一个动作时,Facebook都会发回错误,说该对象属于网站类型。
查看对此线程的前两个响应。
此线程也可能对您有所帮助。
或者这个。
其他建议:
- fb:app_id标记必须与您尝试使用的应用程序相匹配
- 你确定og:url真的匹配对象的url吗?也许你有og:事件页面上的url标签,它将facebook重定向到某个地方否则没有事件的og标记
- 你是否在另一个应用程序中为对象使用了相同的URL?这也可能造成问题。如果您的网站需要登录,这也可能是一个问题
我最终创建了一个新的Facebook应用程序。这个应用程序也有同样的问题,但在对它进行了一点调整后(包括调试器和我的代码(,我开始工作。我不确定这里的收获是什么,但我相信这个问题可能有三个根源,我端的bug,Facebook缓存和缓存。
感谢每一个人的回复。