Javascript API共享函数给出错误

时间:2011-09-09 19:17:35

标签: javascript facebook fbjs

ARG!我遇到了一个问题,试图从生活在Facebook上的Tab应用程序发布到用户提要。

我正在使用FB.ui以这种方式发布到流:

    window.fbAsyncInit = function() {
        FB.init({
          appId  : '<?php echo FACEBOOK_APPLICATION_ID ?>',
          status : true, // check login status
          cookie : true, // enable cookies to allow the server to access the session
          xfbml  : true,  // parse XFBML
          /*channelUrl  : 'http://www.yourdomain.com/channel.html', // Custom Channel URL*/
          oauth : true //enables OAuth 2.0
        });
      };

      (function() {
        var e = document.createElement('script');
        e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
        e.async = true;
        document.getElementById('fb-root').appendChild(e);
      }());

function shareOnFacebook(){
FB.ui({
   method: 'feed',
   name: 'Example',
   link: 'http://example.com',
   picture: 'http://example.com/share.jpg',
   caption: '',
   description: '<?php echo urlencode($shareMessage); ?>'
 });
}

我不断收到消息 “发生了错误,请再试一次。”

当用户授权应用程序时 - 通过PHP SDK - 我要求'publish_stream'权限......并在其他应用程序中使用了这个确切的代码。

有人能指出我的解决方案吗?任何和所有的帮助都非常感谢。

干杯!

2 个答案:

答案 0 :(得分:0)

对于FB.ui你不需要任何权限,因为它是交互式的,并且随意使用,与服务器端无关,你是否有我们可以看到的测试页

答案 1 :(得分:0)

使用此

FB.init({appId: "YOUR_APP_ID", status: true, cookie: true});

  function postToFeed() {

    // calling the API ...
    var obj = {
      method: 'feed',
      redirect_uri: 'YOUR URL HERE',
      link: 'https://developers.facebook.com/docs/reference/dialogs/',
      picture: 'http://fbrell.com/f8.jpg',
      name: 'Facebook Dialogs',
      caption: 'Reference Documentation',
      description: 'Using Dialogs to interact with people.'
    };

    function callback(response) {
      document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
    }

    FB.ui(obj, callback);
  }