Advertisement
janter13

like

Nov 2nd, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.46 KB | None | 0 0
  1. <?php
  2. ob_start('ob_gzhandler');
  3.  
  4. $token = "";
  5. $like_komen = 1; // 1 = on, 2 = off
  6. $me = json_decode(file_get_contents('https://graph.facebook.com/me?access_token='.$token),true);
  7. if($me[id]){
  8. like($me[id], $like_komen,$token);
  9. }else{
  10. exit;
  11. }
  12.  
  13. function _req($url){
  14.    $opts = array(
  15.             19913 => 1,
  16.             10002 => $url,
  17.             10018 => 'MAUI-based Generic / bOt Koplak by Danz Ze',
  18.             );
  19.    $ch=curl_init();
  20.    curl_setopt_array($ch,$opts);
  21.    $result = curl_exec($ch);
  22.    curl_close($ch);
  23.    return $result;
  24.   }
  25.  
  26. function getData($dir,$token,$params){
  27.     $param = array(
  28.         'access_token' => $token,
  29.         );
  30.    if($params){
  31.        $arrayParams=array_merge($params,$param);
  32.        }else{
  33.        $arrayParams =$param;
  34.        }
  35.    $url = getUrl('graph',$dir,$arrayParams);
  36.    $result = json_decode(_req($url),true);
  37.    if($result[data]){
  38.        return $result[data];
  39.        }else{
  40.        return $result;
  41.        }
  42.    }
  43.  
  44. function getUrl($domain,$dir,$uri=null){
  45.    if($uri){
  46.        foreach($uri as $key =>$value){
  47.            $parsing[] = $key . '=' . $value;
  48.            }
  49.        $parse = '?' . implode('&',$parsing);
  50.        }
  51.    return 'https://' . $domain . '.facebook.com/' . $dir . $parse;
  52.    }
  53.  
  54. function getLog($x,$y){
  55.  
  56.    if(file_exists('lk_'.$x)){
  57.        $log=file_get_contents('lk_'.$x);
  58.        }else{
  59.        $log=' ';
  60.        }
  61.  
  62.   if(ereg($y[id],$log)){
  63.        return false;
  64.        }else{
  65. if(strlen($log) > 5000){
  66.    $n = strlen($log) - 5000;
  67.    }else{
  68.   $n= 0;
  69.    }
  70.        saveFile('lk_'.$x,substr($log,$n).' '.$y[id]);
  71.        return true;
  72.       }
  73.  }
  74.  
  75. function saveFile($x,$y){
  76.    $f = fopen($x,'w');
  77.              fwrite($f,$y);
  78.              fclose($f);
  79.    }
  80.  
  81.  
  82. function like($me,$c,$token){
  83. $home=getData('me/home',$token,array(
  84.    'fields' => 'id,from,comments.limit(100),comments.id',
  85.    'limit' => 20,
  86.    )
  87. );
  88.  
  89. foreach($home as $post){
  90.      if($post[id]){ if(getLog($me,$post) && $me!=$post[from][id]){
  91.           print getData($post[id].'/likes',$token,array(
  92.                         'method' => 'post',
  93.                          )
  94.                  );
  95.            } }
  96. if($c==1){
  97. $b = count($post[comments][data]);
  98.  
  99. if($b >0){
  100. if( $b > 5){ $a=$b - 5; }else{ $a=0; }
  101. for($i=$a;$i<$b;$i++){ if($post[comments][data][$i][id]){
  102. if(getLog($me,$post[comments][data][$i])){
  103. getData($post[comments][data][$i][id].'/likes',$token,array('method'=>'post'));
  104. }
  105. }
  106. }
  107. }
  108. }
  109. }
  110. }
  111. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement