JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<script>
var xmlhttp = new XMLHttpRequest();
var url = "https://graph.facebook.com/NCHU.tw/posts?access_token=這裡置入Graph API Explor申請的臨時Access Token試試看&fields=message,picture,link&limit=20";
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var myArr = JSON.parse(xmlhttp.responseText);
myFunction(myArr);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
function myFunction(arr) {
var data = arr.data;
var out = "";
var i;
for(i = 0; i < data.length; i++) {
if ( data[i].picture != undefined ) out += '<img src="' + data[i].picture + '" class="facebook-pics" id="pic' + i+1 + '"/>';
if ( data[i].message != undefined ) out += '<p><a href="' + data[i].link + '" target="_blank">' + data[i].message + '</a></p>';
out += '<p> </p>';
}
document.getElementById("facebook-stuff").innerHTML = out;
}
</script>
</head>
<body>
<div id="facebook-stuff">
</div>
</body>
</html>