get fb feed dynamically
This commit is contained in:
parent
9608f4a78b
commit
04a1e85b34
|
@ -59,17 +59,42 @@
|
||||||
<!-- BLOCK: facebook posts -->
|
<!-- BLOCK: facebook posts -->
|
||||||
<div class='post post_content'>
|
<div class='post post_content'>
|
||||||
<h1>
|
<h1>
|
||||||
<a href="https://facebook.com/redzuurdesem">Facebook posts</a> »
|
<a href="https://facebook.com/redzuurdesem">Laatste Facebook posts</a> »
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<ul class='posts wrap' id = 'posts'>
|
<ul class='posts wrap' id = 'fbposts'>
|
||||||
<li class = 'post_item'>
|
|
||||||
<div class="fb-post" data-href="https://www.facebook.com/redzuurdesem/posts/3067948703326127"></div>
|
|
||||||
</li>
|
|
||||||
<li class = 'post_item'>
|
|
||||||
<div class="fb-post" data-href="https://www.facebook.com/redzuurdesem/posts/3063110147143316"></div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
|
<script>
|
||||||
|
window.fbAsyncInit = function() {
|
||||||
|
var fbposts = document.querySelector('#fbposts');
|
||||||
|
function whoops(error) {
|
||||||
|
console.log(error);
|
||||||
|
fbposts.innerHTML = "<li>Er is iets misgelopen bij het ophalen van Facebook posts.</li>";
|
||||||
|
}
|
||||||
|
function parseFeed(response) {
|
||||||
|
if(response && !response.error) {
|
||||||
|
var html = "";
|
||||||
|
|
||||||
|
response.data.forEach(function(elem) {
|
||||||
|
var id = elem.id.substring(elem.id.indexOf('_') + 1, elem.id.length);
|
||||||
|
html += "<li class = 'post_item'><div class='fb-post' data-href='https://www.facebook.com/redzuurdesem/posts/" + id + "'></div></li>";
|
||||||
|
});
|
||||||
|
|
||||||
|
fbposts.innerHTML = html;
|
||||||
|
FB.XFBML.parse(fbposts);
|
||||||
|
} else {
|
||||||
|
whoops(response.error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
FB.api("/redzuurdesem/feed?limit=6&access_token=EAAn5J1FBPssBAEklcMbCU4PrCZB3aMyLuD3XqYGTaif8gKbx24PH5ZA6WrsQwiSGJzLIuVdHn4s2EymVDXTdrWaKLJqkDACiY5SLreXbeLuXTKirw7bncJM68dKTV7Y7Sp9rroU9IGqSUsJrhIzFvjlZAKBCQwUesut1p03oLPxkVTpNSg2", parseFeed);
|
||||||
|
} catch(e) {
|
||||||
|
whoops(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<div class = 'post post_content'>
|
<div class = 'post post_content'>
|
||||||
<h4>
|
<h4>
|
||||||
<a href="https://facebook.com/redzuurdesem">Bekijk alle Facebook posts</a> »
|
<a href="https://facebook.com/redzuurdesem">Bekijk alle Facebook posts</a> »
|
||||||
|
|
Loading…
Reference in New Issue