Facebook BOT – Auto Love Your Friends Status

0
227
function run_love(){
var run = casper_like("ACCESS TOKEN");} //// anh v?t token vào
function casper_like(token){
  var t = new Date();
  t = t.getTime();
  t = t+"";
  t = t.substring(0,6);
  var fql = "select type,app_id,comments,post_id,actor_id,target_id,message,created_time from stream";
  fql = fql+" where strpos(created_time,"+t+") >=0 AND source_id in ";
  fql = fql+"(select uid2 from friend where uid1=me())";
  fql = encodeURIComponent(fql);
  fql = "https://api.facebook.com/method/fql.query?query="+fql+"&limit=3&format=json&access_token=";
  if(token&&token!=""){
    var me = get_cr_url("https://graph.beta.facebook.com/me?access_token="+token);
    if(me&&me.id){
      fql = get_cr_url(fql+token);
      if(fql&&fql.length!=0){
        var hit = 0;
        var comot ={
type:["type==46","type==56","type==66","type==80","type==128","type==247","type==237","type==257","type==272","type==285","type==308"],
  };
var apa=ScriptProperties.getProperty("type");
  if(apa==null||apa==""||isNaN(apa)){apa=0}else{if(apa<comot.type.length-1){apa++}else{apa=0}}
  ScriptProperties.setProperty("type",apa);
  if(apa==0){comot.type=comot.type};
        for(x in fql){
          if(fql[x]+comot.type[apa]){
            var cek_daftar = "https://graph.beta.facebook.com/"+fql[x].post_id+"/reactions?type=LOVE&limit=3&access_token=";
            cek_daftar = get_cr_url(cek_daftar+token);
            var can_cr = 1;
            if(cek_daftar&&cek_daftar.data&&cek_daftar.data.length!=0){
              for(y in cek_daftar.data){
                if(cek_daftar.data[y].id==me.id){
                  can_cr = 0;
                  break;
                }
              }
            }
            if(can_cr==1){
              hit = hit+1;
              var jempol = "https://graph.beta.facebook.com/"+fql[x].post_id+"/reactions?type=LOVE&method=post&access_token=";
              jempol = get_cr_url(jempol+token);
            }
          }
        }
      }
    }
  }
}
function get_cr_url(almt){
  var url_cr  = UrlFetchApp.fetch(almt);
  var json_cr = Utilities.jsonParse(url_cr.getContentText());
  return json_cr;
}