[英]Facebook javascript login with publish_actions dialogue not working
[英]Facebook login javascript sdk not working with publish_actions scope
我正在使用在本地主機中使用類似按鈕圖API的Web應用程序,但無法正常工作。 當用戶單擊“喜歡”按鈕時,如果fb登錄狀態為“已連接”,則它將調用圖api創建“喜歡”對象,以使“喜歡”用戶成為url。 問題:用戶狀態為“已連接”,但圖形api在調用創建對象(如url)時始終響應“需要擴展權限:publish_actions”。
這是我的代碼:
window.fbAsyncInit = function() {
FB.init({
appId: MY_APP_ID,
status: true,
cookie: true,
xfbml: true
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/vi_VN/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
/////////////////////////
// Login
////////////////////////
function fbLogin() {
FB.login(function(response) {
if (response.authResponse) {
FB.api('/me', function(response) {
//something
});
}
},{scope: 'publish_actions,publish_stream'});
}
/////////////////////////
// btnLike heart click
////////////////////////
jQuery('.hit').click(function() {
var current = jQuery(this);
var postId = current.attr('id');
var url = current.parent().attr('data-href');
var class_string = current.attr('class');
var class_array = class_string.split(' ');
if (class_array.indexOf("liked") != -1) { // found : liked
} else { // not found : not liked
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
FB.api('me/og.likes', 'post', {
/*test*/
object : getTestPermalink(url),
}, function(res) {
if (res.id) { //hit like successful
jQuery.post(
MyAjax.ajaxurl,
{ action: 'set_post_likes', postId: postId },
function(result) {
current.addClass('liked');
current.parent().children('.count').html(result.split('-')[0]);
}
);
}
});
} else {
fbLogin();
}
});
}
});
有人能幫我嗎? 對不起,我的英語不好..
publish_stream
已棄用(自從幾年以來?),您只需要publish_actions。 FB.login
。 您必須在用戶交互(鼠標單擊)時直接調用它,而不是在FB.getLoginStatus
的回調中FB.getLoginStatus
。 話雖如此,如果您不嘗試與應用程序的管理員,開發人員或測試人員一起使用,則通常會彈出權限錯誤。 publish_actions
需求確實已被Facebook批准,其他任何用戶都可以對其進行授權。 查看登錄評論: https : //developers.facebook.com/docs/apps/review/login
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.