Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Import users to the Blocked list of a Facebooks Fan Page
var fpId = '<YOURFANPAGEID>';
var usersText=prompt('Вставьте список пользователей:');
var users = usersText.split('\n');
console.log('Всего пользователей:'+users.length);
var r = /\d+/;
var userIds=[];
for (var i=0;i<users.length;i++){
userIds.push(r.exec(users[i])[0]);
}
var rat = new RegExp("EAABsbCS1[a-zA-Z0-9]*");
var userAccessToken = document.documentElement.innerHTML.match(rat);
var xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
var json = JSON.parse(this.responseText);
var pageAccessToken = json.access_token;
var data = new FormData();
data.append("user", JSON.stringify(userIds));
data.append("access_token", pageAccessToken);
var xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log('Импорт успешно завершён, лейте в плюс!');
}
});
xhr.open("POST", "https://graph.facebook.com/v9.0/"+fpId+"/blocked");
xhr.send(data);
}
});
xhr.open("GET", "https://graph.facebook.com/v9.0/"+fpId+"?fields=access_token&access_token="+userAccessToken);
xhr.send();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment