从FB.ui获取Facebook用户Uid

时间:2010-12-30 17:22:54

标签: facebook

我有这段代码:

 FB.ui(
  {
    method: 'stream.publish',
    attachment: {
      name: 'JSSDK',
      caption: 'The Facebook 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://fbrell.com/'
    },
    action_links: [
      { text: 'fbrell', href: 'http://fbrell.com/' }
    ]
  },
  function(response) {
    if (response && response.post_id) {

/* 
   HERE
*/
      alert('Post was published.');
    } else {
      alert('Post was not published.');
    }
  }
);

在Here Point中,我如何获得用户uid? 我试过:

var user_id = FB.getSession()。uid;一片空白 :(     FB.api( '/我'); //需要OAUTH

但结果为0。 提前谢谢。

1 个答案:

答案 0 :(得分:0)

检查此链接是否可以为您提供帮助。它帮助我完成了一个完美的工作示例。

https://developers.facebook.com/blog/post/525/