2010-11-15 111 views
0

我可以在自己的墙上写字,但不能写在我是管理员的页面墙上。我正在使用下面的代码(Javascript SDK):是否可以发布到您使用Facebook Javascript SDK的管理员的页面?

  FB.ui(
      { 
      method: 'stream.publish', 
      message: 'getting educated about Facebook Connect', 
      attachment: { 
       name: 'Connect', 
       caption: 'The Facebook Connect JavaScript SDK', 
       description: (
       'A small JavaScript library that allows you to harness ' + 
       'the power of Facebook, bringing the user\'s identity, ' + 
       'social graph and distribution power to your site.' 
       ), 
       href: 'http://github.com/facebook/connect-js' 
      }, 
      action_links: [ 
       { text: 'Code', href: 'http://github.com/facebook/connect-js' } 
      ], 
      user_message_prompt: 'Share your thoughts about Connect', 
      target_id: '170500829645508', 
      uid: '100001920038281' 
      }, 
      function(response) { 
      if (response && response.post_id) { 
       alert('Post was published.'); 
      } else { 
       alert('Post was not published.'); 
      } 
      } 
     ); 
     } 

其中目标ID是页面我管理员和uid是我的帐户用户ID。当我运行此代码,我不断收到错误消息:指定

无效目标: 170500829645508.目标必须是一个网页,事件,或用户的演员 可以张贴上墙。

我在这里做错了什么?

回答

0

我结束了使用这种方法,它适用于发布到我管理的页面。还没有想出如何包括附件这种方式虽然...

 var wallPost = { 
     access_token: ".........................", 
     message: 'Here is some more stuff' 
    }; 

    FB.api('/me/feed', 'post', wallPost, function(response) { 
     if (!response || response.error) { 
      alert('Error occurred:' + response.error.message); 
     } else { 
      alert('Success!'); 
     } 
    }); 
1

您需要manage_pages扩展权限才能执行此操作。一旦授予权限,您可以查询graph.facebook.com/me/accounts以检索可以发布到页面墙上的API令牌。查看Facebook的扩展权限:http://developers.facebook.com/docs/authentication/permissions

+0

好吧,我想我有我需要的令牌。现在我该怎么处理它? – 2010-11-16 16:22:01

相关问题