cdw1p

AutoRepost FB With Token

Mar 4th, 2018
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.12 KB | None | 0 0
  1. <?php
  2. #**********************************************#
  3. # AutoRepost Facebook with Unicode Text PHP    *
  4. #**********************************************#
  5.  
  6. class Facebook
  7. {
  8.     public $access_token;
  9.     public $normalText;
  10.     public $target;
  11.     public $style;
  12.     function __construct(){
  13.         #####SETTINGS#####
  14.         $this->access_token = "EAA....."; //access_token facebook
  15.         $this->target = "134484603292036"; //target user id/fp id
  16.         $this->normalText = "yes"; //yes //no
  17.         $this->style = 'Italic+sans+serif';
  18.         //Monospace
  19.         //Parentheses
  20.         //Encircled
  21.         //Fullwidth
  22.         //Bold
  23.         //Script
  24.         //Bold+script
  25.         //Bold+italic
  26.         //Italic
  27.         //Fraktur
  28.         //Double+struck
  29.         //Bold+fraktur
  30.         //Sans+serif
  31.         //Bold+sans+serif
  32.         //Italic+sans+serif
  33.         //Bold+italic+sans+serif
  34.         ####ENDSETTINGS####
  35.     }
  36.     public function getFeed(){
  37.         if(file_exists('log_status')){
  38.             $log=json_encode(file('log_status'));
  39.         }else{
  40.             $log='';
  41.         }
  42.         $data = $this->curl("https://graph.facebook.com/".$this->target."/feed?fields=id,message,type&limit=5&access_token=".$this->access_token);
  43.         $data = json_decode($data);
  44.         foreach ($data->data as $key => $data) {
  45.             $hitung_kata = strlen($data->message);
  46.             if($hitung_kata >= 130){
  47.                 if($data->type=='link'){}else{
  48.                     if(!preg_match("/JUAL|jual|Jual|FOLLOW|Follow|follow|LIKE|Like|like|KOMEN|Komen|komen|Comment|COMMENT|comment|Hub|HUB|hub|KUNJUNGI|Kunjungi|kunjungi|VISIT|Visit|visit/i", @$data->message)){
  49.                         if(!preg_match("/".$data->id."/",$log)){
  50.                             $x=$data->id."\n";
  51.                             $y=fopen('log_status','a');
  52.                             fwrite($y,$x);
  53.                             fclose($y);
  54.                             print 'status terbaru muncul.. repost .....<br>';
  55.                             $this->postStatus($data->message);
  56.                         }else{
  57.                             print 'tidak ada status terbaru<br>';
  58.                         }
  59.                     }
  60.                 }
  61.             }
  62.         }
  63.     }
  64.     public function postStatus($text){
  65.         if($this->normalText =='no'){
  66.             $data = file_get_contents('https://id.8x.cc/random/fancy/fancy.php?style='.$this->style.'&text='.urlencode($text));
  67.             $data = preg_match("'<h2 class=\"red\">(.*?)</h2>'", $data, $match);
  68.             $status = $match[1];
  69.         }else{
  70.             $status = $text;
  71.         }
  72.         $req = $this->curl("https://graph.facebook.com/me/feed",
  73.             array(
  74.                 "message" => $status,
  75.                 "method" => "post",
  76.                 "access_token" => $this->access_token)
  77.         );
  78.         $req = json_decode($req);
  79.         print '<pre>'.print_r($req,1);
  80.         $this->likeStatus($req->id);
  81.     }
  82.     public function likeStatus($id_post){
  83.         $req = $this->curl("https://graph.facebook.com/".$id_post."/likes",
  84.             array(
  85.                 "method" => "post",
  86.                 "access_token" => $this->access_token)
  87.         );
  88.     }
  89.     public function curl($url, $data=null) {
  90.         $c = curl_init();
  91.         curl_setopt($c, CURLOPT_URL, $url);
  92.         if($data != null){
  93.             curl_setopt($c, CURLOPT_POST, true);
  94.             curl_setopt($c, CURLOPT_POSTFIELDS, $data);
  95.         }
  96.         curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
  97.         curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
  98.         curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
  99.         $result = curl_exec($c);
  100.         curl_close($c);
  101.         return $result;
  102.     }
  103. }
  104.  
  105. $data = new Facebook();
  106. $data = $data->getFeed();
Advertisement
Add Comment
Please, Sign In to add comment