我正在尝试将来自Facebook页面的最新帖子嵌入到我的网站中。我过去可以使用graph api做类似的事情来获取最新的facebook帖子的永久链接,然后将data-href设置为永久URL。我的js脚本运行后,fb-post div看起来像这样
<div class="fb-post fb_iframe_widget fb_iframe_widget_fluid" id="update1" data-href="https://www.facebook.com/XXXXXXXXXXXXX/posts/XXXXXXXXXXXXXX/" data-width="500" data-show-text="true" fb-xfbml-state="rendered" fb-iframe-plugin-query="app_id=XXXXXXXXXXXXXX&container_width=735&href=https%3A%2F%2Fwww.facebook.com%2FXXXXXXXXXXXXXXXX%2Fposts%2FXXXXXXXXXXXXXX%2F&locale=en_US&sdk=joey&show_text=true" style="display: block; width: 100%; height: auto;"><span style="vertical-align: top; width: 100%; height: auto; overflow: hidden;"><iframe name="fde9e2f62a5f14" height="1000px" frameborder="0" allowtransparency="true" allowfullscreen="true" scrolling="no" allow="encrypted-media" title="fb:post Facebook Social Plugin" src="https://www.facebook.com/v3.1/plugins/post.php?app_id=XXXXXXXXXXXXX&channel=https%3A%2F%2Fstaticxx.facebook.com%2Fconnect%2Fxd_arbiter%2Fr%2Fmp2v3DK3INU.js%3Fversion%3D42%23cb%3Df238c2f810f2878%26domain%3D%26origin%3Dfile%253A%252F%252F%252Ff39b010532f7664%26relation%3Dparent.parent&container_width=735&href=https%3A%2F%2Fwww.facebook.com%2FXXXXXXXXXXXXXXXX%2Fposts%2FXXXXXXXXXXXXXXXX%2F&locale=en_US&sdk=joey&show_text=true" style="border: none; visibility: visible; height: 0px; position: static; width: 0px;"></iframe></span></div>
告诉我js很好。但是帖子并未显示在页面上。这是我的脚本以及脚本运行之前的初始设置:
var isLoaded;
window.fbAsyncInit = function() {
FB.init({
appId : 'MY_APP_ID',
autoLogAppEvents : true,
xfbml : true,
version : 'v3.1'
});
alert("fbAsyncInit");
FB.AppEvents.logPageView();
isLoaded = 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 = "http://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
var token;
function beepboop() {
if (!isLoaded) {
alert(isLoaded);
setTimeout("beepboop();", .1);
return;
}
else {
alert("loaded");
FB.api(
'/me/feed',
'GET',
{ access_token : 'MY_ACCESS_TOKEN',
"fields":"id"},
function(response) {
for(var i=1; i<=5; i++){
alert(response.data[i].id);
$("#update" + i).attr('data-href', "https://www.facebook.com/" + response.data[i].id.split("_")[0] + "/posts/" + response.data[i].id.split("_")[1] + "/");
alert($("#update"+i).attr('data-href'));
FB.XFBML.parse()
}
//});
//}
}
);
}
}
.column_update{
width: 75%;
float: right;
background-color: rgba(200, 200, 200, .7);
}
.fb-box{
overflow: hidden;
}
<div class="column_update">
<div class="fb-box">
<div class="fb-post" id="update1" data-href="" data-width="500" data-show-text="true">
</div>
</div>
</div>
对于这个超级具体的问题,我真的感到很抱歉,但是我不知道我在做什么错(或者我在做什么)。
非常感谢