Created
August 23, 2018 11:17
-
-
Save htoann/115c4cb77a95166f9e4997024848f816 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
date_default_timezone_set("Asia/Ho_Chi_Minh"); | |
define('ENDPOINT', 'https://graph.fb.me/'); | |
define('ACCESS_TOKEN', 'EAAAAUaZA8jlABAOpLdZBx5yRQjOGKVfrBZCtDkLupiYLosYed5iC3frorACMUdz6RBcBXsoZCTBE9OZBlQqZAbcZAnNYek1rX9uajux3UMZBZBaA30TqOTYie2Dd83xsgOIFbGR9BZA4ZBji4Fcgfb5KeemZBOckiabMydQZD'); // Thay YOUR_ACCESS_TOKEN thành Token của bạn | |
define('YOUR_USER_ID', '100008457526639'); // Thay USER_ID thành ID của bạn | |
$list_reaction = ['LIKE', 'WOW', 'HAHA', 'SAD', 'ANGRY']; // List Reactions | |
$list_user = ['100011243765541', '100025310853694', '100004048515716', '100013345245732', '100019724491424', '100016292041021', '100018441253954']; // List User ID Quỳnh Tín Thuần Phin Trung Trãi | |
foreach ($list_user as $userID) { | |
$posts = curl(ENDPOINT.$userID.'/posts?fields=id&limit=1&access_token='.ACCESS_TOKEN); | |
$idFirstPost = $posts->data[0]->id; | |
if(checkReaction($idFirstPost)) { | |
continue; | |
} | |
$reaction = $list_reaction[array_rand($list_reaction)]; | |
$log = curl(ENDPOINT.$idFirstPost.'/reactions?type='.$reaction.'&method=POST&access_token='.ACCESS_TOKEN); | |
if($log->success) { | |
logs(date('d.m.y H:i:s')." | ".$reaction." | ".$idFirstPost." | success\n"); | |
echo 'success'; | |
} | |
else { | |
logs(date('d.m.y H:i:s')." | ERROR | ".$idFirstPost." | ".$log->error->message."\n"); | |
echo 'error'; | |
} | |
} | |
function curl($url) { | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36'); | |
$result = curl_exec($ch); | |
curl_close($ch); | |
return json_decode($result); | |
} | |
function checkReaction($idPost) { | |
$file = file_get_contents('log.txt'); | |
if(strpos($file, $idPost)) { | |
return true; | |
} else { | |
$getReactions = curl(ENDPOINT.$idPost.'/reactions?access_token='.ACCESS_TOKEN); | |
foreach ($getReactions->data as $user) { | |
if(YOUR_USER_ID == $user->id) { | |
return true; | |
break; | |
} | |
} | |
} | |
return false; | |
} | |
function logs($data) { | |
$fileContent = file_get_contents ('log.txt'); | |
file_put_contents('log.txt', $data . "\n" . $fileContent); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment