我已經創建了一個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();
});
});
}
你能迴應來自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
@林果皞我登錄時顯示「成功」警告(應用程序管理員)但是當我用另一個帳戶登錄時,警報返回錯誤消息。並發現「Publish_Stream」在範圍內可用,那麼可能是什麼問題? – Anuya 2013-05-13 08:52:21
@林果皞我認爲在我用來發布FB的腳本中沒有問題,因爲它在登錄時運行正常。 f中缺少的任何東西acebook開發人員儀表板,我做錯了?請幫忙。 – Anuya 2013-05-13 08:58:59