JSFiddle - React, Tailwind, and code Playground
by yassinezerguine
HTML
<div>
<label>post to timeline</label>
<input type="text" id="text">
<input type="button" value="send" id="post">
<br>
<label>post comments on all feed in the timeline</label>
<input type="text" id="text3">
<input type="button" value="send" id="post3">
<br>
<label>post replies to all comments</label>
<input type="text" id="text2">
<input type="button" value="send" id="post2">
</div>
JavaScript
$(function(){
access_token = "EAACiDNXx1s4BAPnfTjtZBHmTVlFuoijmrURhd6IUz7RZAfmrSs3OOapZAJV3ibTyF3FjUYN46RZATQ9Oa8ZA50owWxPrXOJ9SexhOIIt10UxKZCZAvRRZAGUxfJj2JM3ptAc0z6ruPymawZBwrfKTb5wzpqU07ZCyZAkawZD";
page_id = 'me';
window.fbAsyncInit = function() {
FB.init({
appId : '178176012703438',
xfbml : true,
version : 'v2.8',
channelURL : '', // Channel File, not required so leave empty
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
oauth : true, // enable OAuth 2.0
});
FB.AppEvents.logPageView();
};
(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 = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.8&appId=178176012703438";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
$("#post").click(function(){
var text =$("#text").val();
if(text.length>0){
FB.api(
"/me/feed",
"POST",
{
"message": text,
"access_token" : access_token
},
function (response) {
if (response && !response.error) {
}
else {
alert("error 1 "+response.error.message);
}
}
);
$("#text").val('');
}
});
$("#post2").click(function(){
var text2 =$("#text2").val();
if(text2.length>0){
FB.api(
"/me/feed?fields=comments",
'GET',
{access_token: access_token},
function (response) {
if (response && !response.error) {
$.each(response.data, function(index1, data1){
var dataresponse =response.data[index1].comments.data;
$.each(dataresponse, function(index, data) {
FB.api(
"/"+dataresponse[index].id+"/comments",
"POST",
{
"message":...