Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined("DATA") || exit("No Direct Script Access Allowed !");
- /**
- * @author Ammar F. https://www.facebook.com/ammarfaizi2 <ammarfaizi2@gmail.com>
- * @license RedAngel PHP Concept (c) 2016/2017
- */
- class Crayner_Machine{
- protected static function curl($url,$cookies=null,$postfields=null,$return=null){
- $ch = curl_init();
- $options = array(
- CURLOPT_URL=>$url,
- CURLOPT_SSL_VERIFYPEER=>false,
- CURLOPT_RETURNTRANSFER=>true,
- CURLOPT_USERAGENT=>useragent,
- CURLOPT_ENCODING=>"",
- CURLOPT_FOLLOWLOCATION=>true,
- CURLOPT_TIMEOUT=>15
- );
- if ($postfields!==null) {
- $options[CURLOPT_POST] = true;
- $options[CURLOPT_POSTFIELDS] = $postfields;
- }
- if ($cookies!==null) {
- $options[CURLOPT_COOKIEFILE] = cookies."/".$cookies;
- $options[CURLOPT_COOKIEJAR] = cookies."/".$cookies;
- }
- curl_setopt_array($ch,$options);
- //return $options;
- $ch_exec = curl_exec($ch);
- if ($return!==null) {
- if ($return=="curl_getinfo") {
- $return = curl_getinfo($ch);
- curl_close($ch);
- unset($ch,$options,$ch_exec);
- if($cookies!==null){unset($cookies);}
- if ($postfields!==null){unset($postfields);}
- return $return;
- } else
- if ($return=="curl_error") {
- $return = curl_error($ch);
- curl_close($ch);
- unset($ch,$options,$ch_exec);
- if($cookies!==null){unset($cookies);}
- if ($postfields!==null){unset($postfields);}
- return $return;
- } else
- if ($return=="curl_errno") {
- $return = curl_errno($ch);
- curl_close($ch);
- unset($ch,$options,$ch_exec);
- if($cookies!==null){unset($cookies);}
- if ($postfields!==null){unset($postfields);}
- return $return;
- } else
- if ($return=="all") {
- $return = array("curl_error"=>curl_error($ch),"curl_errno"=>curl_errno($ch),"curl_exec"=>$ch_exec,"curl_getinfo"=>curl_getinfo($ch));
- curl_close($ch);
- unset($ch,$options,$ch_exec);
- if($cookies!==null){unset($cookies);}
- if ($postfields!==null){unset($postfields);}
- return $return;
- } else {
- $return = $ch_exec;
- curl_close($ch);
- unset($ch,$options,$ch_exec);
- if($cookies!==null){unset($cookies);}
- if ($postfields!==null){unset($postfields);}
- return $return;
- }
- } else {
- $return = $ch_exec;
- curl_close($ch);
- unset($ch,$options,$ch_exec);
- if ($cookies!==null) {
- unset($cookies);
- }
- if ($postfields!==null) {
- unset($postfields);
- }
- return $return;
- }
- }
- }
- /**
- * @author Ammar F. https://www.facebook.com/ammarfaizi2 <ammarfaizi2@gmail.com>
- * @license RedAngel PHP Concept (c) 2016/2017
- */
- class Facebook extends Crayner_Machine{
- public $username;
- public $email;
- public $password;
- public $access_token;
- public function __construct($email,$password,$access_token=null,$username=null){
- $this->email = $email;
- $this->password = $password;
- $this->access_token = $access_token;
- $this->username = $username;
- }
- public function do_login(){
- if (!isset($this->username)){
- $explode = strpos($this->email,"@")!==false ? explode("@",$this->email) : array($this->email,null);
- } else {
- $explode = array($this->username);
- }
- $user = $explode[0];
- $cookies = $user."_".md5($this->email."_".$this->password).".txt";
- $postfields = "email=".urlencode($this->email)."&pass=".urlencode($this->password)."&login=Log+In";
- $do_login[0] = $this->curl("https://m.facebook.com",$cookies);
- $do_login[1] = $this->curl("https://m.facebook.com/login.php",$cookies,$postfields);
- unset($explode,$user,$postfields,$do_login);
- return strpos(file_get_contents(cookies."/".$cookies),"c_user")!==false ? true : false;
- }
- public function go_to($to,$type=null){
- if (!isset($this->username)){
- $explode = strpos($this->email,"@")!==false ? explode("@",$this->email) : array($this->email,null);
- } else {
- $explode = array($this->username);
- }
- $user = $explode[0];
- $cookies = $user."_".md5($this->email."_".$this->password).".txt";
- $url = $type!==null ? (strpos($type,"web") ? "https://www.facebook.com/" : "https://m.facebook.com/") : "https://m.facebook.com/";
- $do_login[0] = $this->curl($url.$to,$cookies);
- unset($explode,$user,$postfields,$url);
- return strpos(file_get_contents(cookies."/".$cookies),"c_user")!==false ? $do_login[0] : false;
- }
- }
- /**
- * @author Ammar F. https://www.facebook.com/ammarfaizi2 <ammarfaizi2@gmail.com>
- * @license RedAngel PHP Concept (c) 2016/2017
- */
- class Messenger extends Facebook{
- public $messenger_postfields;
- public $cookies;
- public function __construct($cookies,$messenger_postfields){
- $this->messenger_postfields = $messenger_postfields;
- $this->cookies = $cookies;
- }
- /**
- * @return (string)
- */
- public function change_color($color,$gcid){
- $ch = curl_init();
- $header[] = "Cookie: ".$this->cookies;
- curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
- curl_setopt($ch,CURLOPT_URL,"https://www.messenger.com/messaging/save_thread_color/?source=thread_settings&dpr=1");
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
- curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
- curl_setopt($ch,CURLOPT_USERAGENT,useragent);
- curl_setopt($ch,CURLOPT_POST,true);
- curl_setopt($ch,CURLOPT_POSTFIELDS,"color_choice=".urlencode($color)."&thread_or_other_fbid=".$gcid."&".$this->messenger_postfields);
- //curl_setopt($ch,CURLOPT_COOKIEJAR,$cookies);
- //curl_setopt($ch,CURLOPT_COOKIEFILE,$cookies);
- curl_setopt($ch,CURLOPT_ENCODING,"");
- curl_setopt($ch,CURLOPT_TIMEOUT,30);
- $data = curl_exec($ch);
- if ((bool)curl_errno($ch)!==false) {
- $error = curl_error($ch);
- curl_close($ch);
- return $error;
- } else {
- curl_close($ch);
- return $data;
- }
- }
- /**
- * @return (string)
- */
- public function remove_participant($participant_id,$gcid){
- $ch = curl_init();
- $header[] = "Cookie: ".$this->cookies;
- curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
- curl_setopt($ch,CURLOPT_URL,"https://www.messenger.com/chat/remove_participants/?uid=".$participant_id."&tid=".$gcid."&dpr=1");
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
- curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
- curl_setopt($ch,CURLOPT_USERAGENT,useragent);
- curl_setopt($ch,CURLOPT_POST,true);
- curl_setopt($ch,CURLOPT_POSTFIELDS,$this->messenger_postfields);
- //curl_setopt($ch,CURLOPT_COOKIEJAR,$cookies);
- //curl_setopt($ch,CURLOPT_COOKIEFILE,$cookies);
- curl_setopt($ch,CURLOPT_ENCODING,"");
- curl_setopt($ch,CURLOPT_TIMEOUT,30);
- $data = curl_exec($ch);
- if ((bool)curl_errno($ch)!==false) {
- $error = curl_error($ch);
- curl_close($ch);
- return $error;
- } else {
- curl_close($ch);
- return $data;
- }
- }
- /**
- * @return (string)
- */
- public function add_participant($participant_id,$gcid){
- $ch = curl_init();
- $header[] = "Cookie: ".$this->cookies;
- curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
- curl_setopt($ch,CURLOPT_URL,"https://www.messenger.com/messaging/send/?dpr=1");
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
- curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
- curl_setopt($ch,CURLOPT_USERAGENT,useragent);
- curl_setopt($ch,CURLOPT_POST,true);
- curl_setopt($ch,CURLOPT_POSTFIELDS,$this->messenger_postfields."&log_message_data[added_participants][0]=fbid%3A".$participant_id."&action_type=ma-type%3Alog-message&thread_fbid=".$gcid."&log_message_type=log%3Asubscribe");
- //curl_setopt($ch,CURLOPT_COOKIEJAR,$cookies);
- //curl_setopt($ch,CURLOPT_COOKIEFILE,$cookies);
- curl_setopt($ch,CURLOPT_ENCODING,"");
- curl_setopt($ch,CURLOPT_TIMEOUT,30);
- $data = curl_exec($ch);
- if ((bool)curl_errno($ch)!==false) {
- $error = curl_error($ch);
- curl_close($ch);
- return $error;
- } else {
- curl_close($ch);
- return $data;
- }
- }
- public function change_thread_name($new_name,$gcid){
- $ch = curl_init();
- $header[] = "Cookie: ".$this->cookies;
- curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
- curl_setopt($ch,CURLOPT_URL,"https://www.messenger.com/messaging/send/?dpr=1");
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
- curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
- curl_setopt($ch,CURLOPT_USERAGENT,useragent);
- curl_setopt($ch,CURLOPT_POST,true);
- curl_setopt($ch,CURLOPT_POSTFIELDS,$this->messenger_postfields."&log_message_data[added_participants][0]=fbid%3A".$participant_id."&action_type=ma-type%3Alog-message&thread_fbid=".$gcid."&log_message_type=log%3Asubscribe");
- //curl_setopt($ch,CURLOPT_COOKIEJAR,$cookies);
- //curl_setopt($ch,CURLOPT_COOKIEFILE,$cookies);
- curl_setopt($ch,CURLOPT_ENCODING,"");
- curl_setopt($ch,CURLOPT_TIMEOUT,30);
- $data = curl_exec($ch);
- if ((bool)curl_errno($ch)!==false) {
- $error = curl_error($ch);
- curl_close($ch);
- return $error;
- } else {
- curl_close($ch);
- return $data;
- }
- }
- }
- /**
- * @author Ammar F. https://www.facebook.com/ammarfaizi2 <ammarfaizi2@gmail.com>
- * @license RedAngel PHP Concept (c) 2016/2017
- */
- class Graph extends Facebook{
- public function get_user_info($user=null){
- return $user===null ? json_decode($this->curl("https://graph.facebook.com/me/?fields=id&access_token=".$this->access_token),true) : json_decode($this->curl("https://graph.facebook.com/".$user."/?field=id&access_token=".$this->access_token),true);
- }
- public function do_like($fbid,$access_token=null){
- $token = $access_token!==null ? $access_token : $this->access_token;
- return $this->curl("https://graph.facebook.com/".$fbid."/likes?method=post&access_token=".$token);
- }
- public function get_newpost($userid="me"){
- if ($userid=="me") {
- $a = $this->get_user_info();
- $b = json_decode($this->curl("https://graph.facebook.com/".$a['id']."/feed?fields=id&limit=1&access_token=".$this->access_token),true);
- $c = explode("_",$b['data'][0]['id']);
- unset($a,$b,$userid);
- return end($c);
- } else {
- $a = json_decode($this->curl("https://graph.facebook.com/".$userid."/feed?fields=id&limit=1&access_token=".$this->access_token),true);
- $b = explode("_",$a['data'][0]['id']);
- unset($a,$userid);
- return end($b);
- }
- }
- public function like_my_newpost($access_token=null){
- return $access_token!==null ? $this->do_like($this->get_newpost(),$access_token) : $this->do_like($this->get_newpost());
- }
- }
- ?>
Add Comment
Please, Sign In to add comment