-
-
Save tdtgit/d9fcab20b13e35c239ccfbf4a59c3c2a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/* Developed by Juno_okyo */ | |
/* Edited by tdtgit */ | |
// EDIT HERE | |
define('ACCESS_TOKEN', 'YOUR_ACCESS_TOKEN'); | |
// EDIT HERE | |
// ID thành viên sẽ bị bỏ qua khi quét | |
$ignoreID = array( | |
'100001518861027', | |
'100002522204671' | |
); | |
// EDIT HERE | |
// Huong dan: scan(ID nguoi dung hoac group_ID cua bai viet, so nguoi may man, so luong comment cua bai viet) | |
scan('100003880469096_499340353731423', 3, 100); | |
function request($url) | |
{ | |
if ( ! filter_var($url, FILTER_VALIDATE_URL)) { | |
return FALSE; | |
} | |
$options = array( | |
CURLOPT_URL => $url, | |
CURLOPT_RETURNTRANSFER => TRUE, | |
CURLOPT_HEADER => FALSE, | |
CURLOPT_FOLLOWLOCATION => TRUE, | |
CURLOPT_ENCODING => '', | |
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.87 Safari/537.36', | |
CURLOPT_AUTOREFERER => TRUE, | |
CURLOPT_CONNECTTIMEOUT => 15, | |
CURLOPT_TIMEOUT => 15, | |
CURLOPT_MAXREDIRS => 5, | |
CURLOPT_SSL_VERIFYHOST => 2, | |
CURLOPT_SSL_VERIFYPEER => 0 | |
); | |
$ch = curl_init(); | |
curl_setopt_array($ch, $options); | |
$response = curl_exec($ch); | |
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
curl_close($ch); | |
unset($options); | |
return $http_code === 200 ? $response : FALSE; | |
} | |
function scan($postId, $personLimit, $commentLimit) { | |
$graph = request('https://graph.facebook.com/v2.9/' . $postId . '/comments?fields=message,from{id}&limit=' . $commentLimit . '&access_token=' . ACCESS_TOKEN); | |
if ($graph !== FALSE) { | |
$json = json_decode($graph); | |
$result = []; | |
if (isset($json->data) && count($json->data) > 0) { | |
foreach ($json->data as $comment) { | |
if (strpos($comment->message, '.facebook.com/groups/') !== FALSE && in_array($comment->from->id, $ignoreID) == FALSE) { | |
$result[] = $comment->id; | |
} | |
} | |
// Get random comments | |
for ($i=0; $i < $personLimit; $i++) { | |
echo $result[array_rand($result)] . '<br>'; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment