4

我已经创建了一个Facebook应用程序。在我的网站上,用户可以使用他们的Facebook帐户登录。一旦他们成功登录,我使用的Facebook JavaScript API将在他们的许可下将URL发送给用户的新进源。Facebook应用程序仅适用于管理员。为什么?

问题是,当我使用我的帐户从网站登录时,这是完美的工作,我可以在我的新闻源中看到帖子。

当用他人帐号登录时,该帖子在他们的新闻源中没有看到。

注意:我是Facebook应用程序的唯一管理员,沙箱模式已禁用。

是否有任何设置需要使此功能适用于所有用户?

代码中使用:

//Get values from hidden field 
var appid = document.getElementById("appid").value; 
var message = document.getElementById("message").value; 
var link = document.getElementById("link").value; 
var name = document.getElementById("name").value; 
var picture = document.getElementById("picture").value; 
var description = document.getElementById("description").value; 
var Post_to_fb = document.getElementById("Post_to_fb").value; 


var Authenticated = ""; 
// Load the SDK Asynchronously 
(function (d) { 
    var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; 
    if (d.getElementById(id)) { return; } 
    js = d.createElement('script'); js.id = id; js.async = true; 
    js.src = "//connect.facebook.net/en_US/all.js"; 
    ref.parentNode.insertBefore(js, ref); 
} (document)); 

//Init the SDK upon load 
window.fbAsyncInit = function() { 
    FB.init({ 
     appId: appid, // App ID 
     channelUrl: '//' + window.location.hostname + '/channel', // Path to your Channel File 
     status: true, // check login status 
     cookie: true, // enable cookies to allow the server to access the session 
     xfbml: true // parse XFBML 
    }); 



    // listen for and handle auth.statusChange events 
    FB.Event.subscribe('auth.statusChange', function (response) { 
     if (response.authResponse) { 
      // user has auth'd your app and is logged into Facebook 
      var uid = "http://graph.facebook.com/" + response.authResponse.userID + "/picture"; 
      FB.api('/me', function (me) { 
       document.getElementById('auth-displayname').innerHTML = me.name; 
       document.getElementById('profileImg').src = uid; 
      }) 
      document.getElementById('auth-loggedout').style.display = 'none'; 
      document.getElementById('auth-loggedin').style.display = 'block'; 

      var e = document.getElementById("ctl00_cphRightControls_FaceBookPlugin_ddlSocialSwitch"); 
      var Social_switch = e.options[e.selectedIndex].text; 

      //Post to FB only if Social switch is ON 
      if (Social_switch == "on") { 
       //Post to FB only for Main URL and not when clicking the internal links 
       if (Post_to_fb == "True") { 

       var opts = { 
        message: message, 
        link: link, 
        name: name, 
        picture: picture, 
        description: description 
       }; 

       FB.api('/me/feed', 'post', opts, function (response) { 
        if (!response || response.error) { 
//      alert('Posting error occured'); 
        } 
        else { 
//      alert('Success - Post ID: ' + response.id); 
        } 
       }); 
       } 
      } 

     } else { 
      // user has not auth'd your app, or is not logged into Facebook 
      document.getElementById('auth-loggedout').style.display = 'block'; 
      document.getElementById('auth-loggedin').style.display = 'none'; 
     } 

    }); 
    $("#auth-logoutlink").click(function() { 
     FB.logout(function() { 
      window.location.reload(); 
     }); 
    }); 
} 
+0

你能回应来自B.api('/ me/feed','post',opts,function(response)的纯文本回应吗?如果成功,你可以得到post_id,或者你比较admin和fake我想确定你是否成功发布,如果不成功,请在https://developers.facebook.com/tools/debug上调试你的用户访问令牌(不是App访问令牌!),并确保你看到“Scope”with“publish_stream”权限 – 2013-05-10 17:13:34

+0

@林果皞我登录时显示“成功”警告(应用程序管理员)但是当我用另一个帐户登录时,警报返回错误消息。并发现“Publish_Stream”在范围内可用,那么可能是什么问题? – Anuya 2013-05-13 08:52:21

+0

@林果皞我认为在我用来发布FB的脚本中没有问题,因为它在登录时运行正常。 f中缺少的任何东西acebook开发人员仪表板,我做错了?请帮忙。 – Anuya 2013-05-13 08:58:59

回答

1

尝试清除日志之间你的cookies您的管理员帐户转移到你的dev的帐户,甚至更好只是测试使用不同的浏览器(chrome profiles是为这个伟大的)

facebook js sdk为用户创建的cookie(fbsr_ {APP_ID})会在第一次加载下一个用户登录时坚持使用它,并在第一次加载页面时将其加固你提到)。在一个浏览器中使用多个账户的Facebook并没有完全简化,开发人员经常使用它们。这很可能是因为它试图作为错误的用户发布并导致错误。这是我最好的猜测,没有更多的信息。

相关问题