问题描述
在 Facebook的开放式图表教程中,我已经尝试构建我们下一个应用程序的基础/ a>但是由于某些原因,我收到错误,不管我如何尝试POST动作。
我将尽可能深入地在这里,我希望这将对所有开发人员掌握新的时间线非常有用。
我已经定义了一个战斗操作和英雄对象,使用默认设置设置每个对象。 transcendgame 是我的命名空间。
$ id
是Facebook用户的用户标识我试过使用/ me /,直接的id对于我来说一直没有太多的问题)。
$ herourl
是一个urlencoded字符串,指向具有以下内容的单独网页:
$herourl
is an urlencoded string pointing to a separate webpage with the following content:
<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# transcendgame: http://ogp.me/ns/fb/transcendgame#">
<meta property="fb:app_id" content="[my id]">
<meta property="og:type" content="transcendgame:hero">
<meta property="og:url" content="http://apps.facebook.com/transcendgame/">
<meta property="og:title" content="Hercules">
<meta property="og:description" content="As this game is still in development, you can ignore this feed post!">
<meta property="og:image" content="[an image url]">
应用程序画布页面包含以下代码。它应该为用户的时间轴POST一个新的动作事件,但一直给我发生错误。我也尝试了与样品英雄对象(samples.ogp.me ...)同样的问题。
<script>
function doTest()
{
FB.api('/<?=$id?>/transcendgame:battle' +
'?hero=<?=$herourl?>','post',
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post was successful! Action ID: ' + response.id);
}
});
}
</script>
<a href="#" onclick="doTest(); return false">Test fb post</a>
我正在调用JS SDK并正确运行fb.init。我真的不知道问题在哪里,更不用说如何解决它。
I've correctly added the user's access token to the API call:
FB.api('/me/transcendgame:battle' +
'?hero=<?=$herourl?>&access=<?=$token?>','post',
However, I'm getting the following error:
Type: OAuthException
Message: (#3502) Object at URL [url] has og:type of 'game'. The property 'hero' requires an object of og:type 'transcendgame:hero'.
这是奇怪的,因为网页确实有og:类型设置正确,如前面列出的这个问题,这是一些Facebook打嗝我需要解决?
SECOND EDIT: Fixed the final problem.
og:url 我假设指向应用程序c的URL anvas,但它需要引用本身。例如,如果您的对象位于mydomain.com/object1.php,那么代码必须是:
<meta property="og:url" content="http://www.mydomain.com/object1.php">
推荐答案
I have the same problem and I changed the callback to be more helpful:
var fb_url = '/me/YOUR_NAMESPACE?key=value';
FB.api(fb_url,'post',
function(response) {
console.log(response);
if (!response || response.error) {
var msg = 'Error occured';
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);
}
}
);
我终于收到了一篇文章到时间轴,我所做的更改是使用BETA版本的JavaScript SDK。 ( https://developers.facebook.com/support/beta-tier/ )
I finally got a post to the timeline, and the change I had to make was to use the BETA version of JavaScript SDK. ( https://developers.facebook.com/support/beta-tier/ )
使用此选项:
<script src="//connect.beta.facebook.net/en_US/all.js#appId=xxx&xfbml=1"></script>
而不是这样:
<script src="//connect.facebook.net/en_US/all.js#appId=xxx&xfbml=1"></script>
这篇关于向时间线发布操作困难的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!