未知的路径组件

时间:2012-02-24 21:44:11

标签: javascript facebook facebook-graph-api opengraph

我尝试发布“观看”动作,但我总是犯这个错误:

Error occured

Type: OAuthException

Message: Unknown path components: /MyAppName:watch

这是我的JS功能:

function postWatch()
  {
FB.api('/me/MyAppName:watch' + 
    '?video=http//myLink.com','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);
    }
    });
  }

这是我的og:标签

<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# video: http://ogp.me/ns/video#">
    <meta property="fb:app_id" content="MyAppID" />
    <meta property="og:title" content="MyTitle" />
    <meta property="og:image" content="http://MyUrlImage.com" />
    <meta property="og:description" content="MyDescription" />
    <meta property="og:url" content="MyLink.com">
    <meta property="og:site_name" content="MySiteName" />
    <meta property="og:type" content="video.movie" /> 

有什么想法吗?

谢谢;)

PS:抱歉我的英语很差,我是法国人;)

此致

2 个答案:

答案 0 :(得分:4)

对于内置操作,语法不同。使用video.watches

答案 1 :(得分:2)

实际上,对于您自己的动作/对象,您可以使用下一个语法:

var params = {};
params['video'] = 'http://example.com/myvideo.html';
FB.api('me/mynamespace:watch','post',params,function(response){
       console.log(response);
});

如果您的用户提供了 publish_actions 权限,这实际上会在您的墙上发布与该对象相关的操作。 对于权限,您可能希望确保您拥有该权限,因此您的检查应如下所示:

FB.api('me/permissions','get',function(response){
       if (response.data[0].publish_actions){
          //do your magic
       }      
});