Skip to content

Instantly share code, notes, and snippets.

@yawo
Last active February 1, 2017 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yawo/05072d034fe557e975c95e25618dd2a0 to your computer and use it in GitHub Desktop.
Save yawo/05072d034fe557e975c95e25618dd2a0 to your computer and use it in GitHub Desktop.
Change post visibility
$(document).ready(function() {
$.ajaxSetup({
cache: true
});
$.getScript('//connect.facebook.net/en_US/sdk.js', function() {
FB.init({
appId: 'YOUR APPID', //281707958585235
version: 'v2.8' // or v2.1, v2.2, v2.3, ...
});
updateFeeds({privacy:{value:'SELF'}});
});
});
var pageSize=1000;
userIdPrefix="/1375851602"
var token= "GET ONE WITH GRAPH EXPLORER"
function updateFeeds(fields) {
FB.api(
userIdPrefix+'/posts',
'GET', {
access_token:token,
fields: "id",
limit:pageSize
},
function(response) {
updatePosts(response,fields);
}
);
}
function updatePosts(feeds,fields) {
if(feeds.data && feeds.data.length){
for(p in feeds.data){
var post=feeds.data[p];
var url = "/"+post.id;
console.log(url);
FB.api(
url,
'post',
{privacy:{value:'SELF'}},
function(response) {
console.log("Done -- ",post.id);
}
);
}
}
if(feeds.paging && feeds.paging.next){
console.log("fetching next ",pageSize, "...");
$.getJSON(feeds.paging.next,function(nextfeeds){
updatePosts(nextfeeds, fields);
});
}else{
console.log("#################### END");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment