簡體   English   中英

如何獲得在 facebook 牆上發布的publish_stream 權限?

[英]how to get publish_stream permissions for post on facebook wall?

這是我的連接:

window.fbAsyncInit = function () {
    FB.init({
        appId: "348044465251207",
        status: true,
        cookie: true,
        xfbml: true,
        oauth: true
    });
    FB.Event.subscribe('auth.login', function (response) {
    var credentials = { uid: response.authResponse.userID, accessToken: response.authResponse.accessToken };
        SubmitLogin(credentials);
    }, { perms: 'read_stream,publish_stream,offline_access' });




    FB.getLoginStatus(function (response) {
        if (response.status === 'connected') {
            FB.api('/me', function (response) {
                //console.log('Good to see you, ' + response.name + '.');

                mail = response.email;
                currentName = response.name;
                gender = response.gender;
                place = response.location;

                $.ajax({
                    url: "/Login/DetailsToDataBase",
                    type: "POST",
                    data: { gender: gender, mail: mail, place: place },

                    success: function (data) {
                        generalScore = data;
                        div_element = document.getElementById("userScore");
                        div_element.innerHTML = "Your score is: " + generalScore;
                    }

                });

            });
        } //end if
        else if (response.status === 'not_authorized') { alert("user is not authorised"); }
        else { alert("user is not conntected to facebook"); }

    }, { scope: 'read_stream,publish_stream,offline_access' });

    function SubmitLogin(credentials) {
        $.ajax({
            url: "/Login/FacebookLogin",
            type: "POST",
            data: credentials,
            error: function () {
                alert("error logging in to your facebook account.");
            },
            success: function () {
              //  alert("success log in facebook");
                //     window.location.reload();
            }
        });
    }

};

(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));

這是在用戶 facebook 牆上發布的功能:

var params = {};
params['method'] = 'stream.publish';
params['message'] = currentName +' earn '+ score+ '$ in battelship!';
params['name'] = 'BattelShip';
params['description'] = 'let\'s see if you sucsses to break my highlight';
params['link'] = 'https://apps.facebook.com/348044465251207/?fb_source=search&ref=ts&fref=ts';
params['picture'] = 'http://www.israup.net/images/98d0808995e356818a0c016bc1a2a7cc.png';
params['caption'] = 'Try it by Yourself!';

FB.api('/me/feed', 'post', params, function(response) {
  if (!response || response.error) {
    console.log('Error occured');
  } else {
    console.log('Published to stream - you might want to delete it now!');
  }

});

它只張貼在我的牆上(因為我是應用程序的管理員),但對於其他用戶,它說:“用戶尚未授權應用程序執行此操作”

請幫幫我!!

我認為您需要再次查看登錄文檔,您在登錄流程“perms”的一部分中使用了一個參數,該參數在一年前已被棄用,以支持“范圍”-

檢查 SDK 附帶的示例並閱讀登錄文檔,盡管如果您修復該錯誤,代碼可能會正常工作,但我會警惕 API 中的其他內容發生了哪些變化,因為您正在使用的示例已編寫完成- 您可以通過使用該訪問令牌調用 /me/permissions 來檢查授予您正在使用的訪問令牌的權限

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM