jnck

Auto Reply Comments Simsimi

Jan 27th, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.15 KB | None | 0 0
  1. <?php
  2. $token = "access_token";
  3.  
  4. function curl($url, $post=null) {
  5.     $ch = curl_init();
  6.     curl_setopt($ch, CURLOPT_URL, $url);
  7.     if ($post!=null) {
  8.         curl_setopt($ch, CURLOPT_POST, true);
  9.         curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  10.     }
  11.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  12.     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  13.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  14.     $eks = curl_exec($ch);
  15.     return json_decode($eks);
  16. }
  17. function simsimi($str) {
  18.     $jawab = curl("http://simsimi.com/getRealtimeReq?uuid=r5KZWDNqCpbqxlqfWisboiisKRmaNRHHMTlmHBFJZpV&lc=id&ft=0&reqText=".urlencode($str)."&status=W");
  19.     if ($jawab->respSentence) {
  20.         $pesen = $jawab->respSentence;
  21.     } else {
  22.         $pesen = ":p";
  23.     }
  24.     $preg = preg_replace("/simsimi|simi|Simsimi|Simi|.simi|sim/is", " w", $pesen);
  25.     return $preg;
  26. }
  27.  
  28. $me = curl("https://graph.facebook.com/me?access_token={$token}");
  29. $penta = curl("https://graph.facebook.com/me/home?access_token={$token}&fields=id,from,message&limit=10")->data;
  30. if (file_exists("log.txt")) {
  31.     $log = json_encode(file("log.txt"));
  32. } else {
  33.     $log = "";
  34. }
  35. foreach ($penta as $data) {
  36.     $com = curl("https://graph.facebook.com/{$data->id}/comments?access_token={$token}&fields=id,message,from&method=get");
  37.     if (sizeof($com->data) > 0) {
  38.         foreach ($com->data as $kom) {
  39.             if (eregi($kom->id, $log)) {
  40.                 echo "sudah";
  41.             } else {
  42.                 $x = "{$kom->id} \n";
  43.                 $y = fopen("log.txt", "a");
  44.                 fwrite($y, $x);
  45.                 fclose($y);
  46.  
  47.                 $naon = $kom->message;
  48.                 $euy = simsimi($naon);
  49.                 $mesej = "( ".$kom->from->name." : ".$naon." ) 👉 ".$euy;
  50.                 $mess = rawurlencode($mesej);
  51.                 if ($kom->from->id!==$me->id) {
  52.                     curl("https://graph.facebook.com/{$data->id}/comments","access_token={$token}&method=post&message={$mess}");
  53.                     curl("https://graph.facebook.com/{$data->id}/likes", "access_token={$token}&method=post");
  54.                 }
  55.             }
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment