2016-02-04 60 views
0

我做了一個FB.api,得到我的Facebook頁面的最後2個職位。我將它添加到我的個人網站。它適用於我的網站,但是當別人訪問我的網站時,他們看不到我最後的帖子...當我搜索到這個問題時,我看到我的FB應用程序需要生效。所以我做到了。但它仍然無法正常工作......Facebook的SDK不公開爲訪問者

這裏是我的代碼:

window.fbAsyncInit = function() { 
     FB.init({ 
      appId: 'APP_ID', // App ID 
      status: true, // check login status 
      cookie: true, // enable cookies to allow the server to access the session 
      xfbml: true // parse XFBML 
     }); 

    }; 

    function toonID() { 
     FB.api('/PAGE_ID/feed?limit=2', function (response) { 
      var str = ""; 
      for (var i = 0; i < response.data.length; i++) { 
       //console.log(i + " : " + response.data[i].message); 
       //str += "<b>id: </b>" + response.data[i].id.slice(16) + "<br><br />"; 
       str += "<div class='fb-post' data-href='https://www.facebook.com/Beatpounce/posts/" + response.data[i].id.slice(16) + "' data-width='466'></div><br /><br />"; 
      } 
      document.getElementById("post").innerHTML = str; 
     }); 
    } 

我想我需要一個acces_token,但我不知道如何使用

+0

「它doesn't工作」是不足夠的錯誤描述,請調試代碼,並試圖找出究竟哪裏問題是。 – luschn

+0

需要訪問令牌來請求此資源。這是錯誤.. –

回答