SHARE
TWEET

Auto reaction facebook + auto refresh token

dimaslanjaka Nov 3rd, 2018 (edited) 438 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. @ini_set('output_buffering',0);
  3. @ini_set('max_execution_time',0);
  4. @ignore_user_abort(1);
  5. session_start();
  6. //*** Copyright Dimas Lanjaka   ***//
  7. //*** BOT REACTION FACEBOOK     ***//
  8. //*** AUTO REFRESH TOKEN        ***//
  9. //*** Auto detect Already Liked ***//
  10. //********* Configuration *********//
  11.  
  12. $user = "username";
  13. //email or username or phone fb
  14. $pass = "password";
  15. //pass fb
  16. $max = "5";
  17. //maximum like per execute
  18. $type = "LOVE";
  19. //LIKE, LOVE, SAD, ANGRY, WOW, HAHA, RANDOM
  20. $useragent = "Mozilla/5.0 (Linux; Android 7.0; Redmi Note 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.80 Mobile Safari/537.36";
  21. //Useragent yang akan digunakan
  22. //Pastikan sama dengan useragent browser yang anda gunakan di browser
  23.  
  24. //********* END Configure *********//
  25. $pass = urlencode($pass);
  26. $user = urlencode($user);
  27. global $user;
  28. global $pass;
  29. define("type", strtoupper($type), true);
  30. define("max", $max, true);
  31.  
  32.  //die(var_dump($user,$pass,$type,$max));
  33.    //error_reporting(0);
  34.  
  35. function setx($x){
  36.   $X = file_put_contents("results.html", $x, FILE_APPEND | LOCK_EX);
  37.   if ($X){ return false; }
  38.   }
  39.       if (!is_dir("tokens")){
  40.         $oldmask = umask(0);
  41.         mkdir("tokens", 0777);
  42.         umask($oldmask);
  43.       }
  44.       if (!is_dir("cache")){
  45.         $oldmask = umask(0);
  46.         mkdir("cache", 0777);
  47.         umask($oldmask);
  48.       }
  49. function post_data($url, $post=null, $opt=null){
  50.   global $useragent;
  51. $ch = curl_init();
  52. curl_setopt($ch, CURLOPT_URL, $url);
  53. if($post != null){
  54. curl_setopt($ch, CURLOPT_POST, true);
  55. curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  56. }
  57. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  58. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  59. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  60. if (!isset($opt["referer"])){
  61. curl_setopt( $ch, CURLOPT_REFERER, $url );
  62. } else {
  63.   curl_setopt($ch, CURLOPT_REFERER, $opt["referer"]);
  64. }
  65. curl_setopt( $ch, CURLOPT_USERAGENT, $useragent );
  66. if (!file_exists("cache/cookies.txt")){file_put_contents("cache/cookies.txt","");}
  67. $cookie = realpath("cache/cookies.txt");
  68. curl_setopt( $ch, CURLOPT_COOKIEJAR,  $cookie );
  69. curl_setopt( $ch, CURLOPT_COOKIEFILE, $cookie );
  70. $exec = curl_exec($ch);
  71. curl_close($ch);
  72. return $exec;
  73. }
  74.  
  75. function refresh_token($user,$pass){
  76.   global $useragent;
  77.   $url = "http://dimaslanjaka.000webhostapp.com/instagram/refreshtoken.php?user=".$user."&pass=".$pass."&useragent=".base64_encode($useragent);
  78.   //$_SESSION["url"]=$url;
  79.   $token = file_get_contents($url);
  80.   $json = json_decode($token, true);
  81.   if (json_last_error() === 0) {
  82.   $token = $json["access_token"];
  83.   } else if (ctype_alnum($token) && count($token) > 150){
  84.     $token = $token;
  85.   }
  86.   file_put_contents("tokens/token.txt", $token, LOCK_EX);
  87.   return $token;
  88. }
  89.  
  90. if (file_exists("tokens/token.txt")){
  91.   $token = file_get_contents("tokens/token.txt");
  92. } else {
  93. refresh_token($user,$pass);
  94. }
  95.  
  96.  
  97. $opt["referer"]="https://www.facebook.com";
  98. global $useragent;
  99. $opt["useragent"]=$useragent;
  100.  
  101. define("token", $token, true);
  102.  
  103. if(!empty($_GET['token'])) {
  104. $access_token = $_GET['token'];
  105. } elseif (defined("token")){
  106.   $access_token = token;
  107.   } else {
  108.    die('Token Not Found');
  109.    }
  110.  
  111. if(!empty($_GET['type'])) {
  112. $type = strtoupper($_GET['type']);
  113. } else if (defined("type") && strtolower(type) === "random"){
  114.     $type = [
  115.     "LIKE",
  116.     "LOVE",
  117.     "HAHA",
  118.     "WOW",
  119.     "SAD",
  120.     "ANGRY",
  121.     //"THANKFUL",
  122.     //"PRIDE"
  123.     ];
  124.     shuffle($type);
  125.     $type = $type[array_rand($type)];
  126.    }
  127.  
  128. if(isset($_GET["max"])) {
  129.    $max = $_GET["max"];
  130.    } else if (defined("max")){
  131.      $max = max;
  132.      }
  133.  
  134. function gethome($access_token, $max=null){
  135.    global $max; global $opt;
  136.    $url = 'https://graph.facebook.com/v2.11/me/home?fields=id,likes.limit(50).summary(1)&limit='.$max.'&access_token='.$access_token;
  137.    return post_data($url, false, $opt);
  138. }
  139.  
  140.    $homepost = gethome($access_token, $max);
  141.    $stat = json_decode($homepost, true);
  142.    if (null === $stat || isset($stat["error"])){
  143.     $token = refresh_token($user,$pass);
  144.     $homepost = gethome($token, $max);
  145.     $stat = json_decode($homepost, true);
  146.    }
  147.    if (null !== $stat && count($stat['data']) > 0){
  148.    for ($i = 0; $i <= count($stat['data']); $i++) {
  149.    $id = $stat['data'][$i]['id'];
  150.    if (!empty($id) && isset($stat["data"][$i]["likes"]["summary"]["has_liked"]) && $stat["data"][$i]["likes"]["summary"]["has_liked"] === false){
  151.    $post_react = "https://graph.facebook.com/v2.11/".$id."/reactions?";
  152.    $type_react = array(
  153.    "type"=>strtoupper($type),
  154.    "method"=>"post",
  155.    "access_token"=>$access_token
  156.    );
  157.    $check_post = $post_react . "token=" . $access_token;
  158.    
  159.       $send = post_data($post_react, $type_react, $opt);
  160.      
  161.       if (null !== $send){
  162.       $idhtml = 'Content ID : '.$id.' <span style="color:green"> [SUCCESS]</span> Reacted '.$type.' ✓<br>';
  163.       setx($idhtml);
  164.       echo $idhtml;
  165.       }
  166.      } /* if has_liked false */ else {
  167.        echo "Content ID : " . $id . " <span style='color:red'>[FAILED]</span> Has Liked Before.<br/>";
  168.        }
  169.     }
  170.    } // data not empty
  171.    else {
  172.      die("Data Timeline is empty");
  173.      }
  174.      echo '<div><span style="float:right"><a href="results.html">Show Log file</a></span><style>*{word-wrap:break-word;max-width:100%}</style></div>';
  175.      
  176. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top