-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcheck-token-live.php
57 lines (53 loc) · 1.64 KB
/
check-token-live.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* Check token live or die
**/
set_time_limit(0);
error_reporting(0);
$lines = file(__DIR__.'/access_token.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($lines as $line) {
$exp = explode("|", $line);
$access_token = check($exp[0]);
$res = json_decode($access_token)->error;
if ($res->message == "The user is enrolled in a blocking, logged-in checkpoint" && $res->type == "OAuthException") {
remove($exp[0]."|".$exp[1]."|".$exp[2]);
}
}
function check($token) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_COOKIEJAR, "");
curl_setopt($ch, CURLOPT_COOKIEFILE, "");
curl_setopt ($ch, CURLOPT_URL, "https://graph.facebook.com/me?access_token=".$token);
$response = curl_exec($ch);
if(false === $response)
{
if(curl_errno($ch))
{
echo 'Curl error: ' . curl_error($ch);
}
die("error, curl_exec failed");
}
return $response;
}
function remove($pattern_to_match) {
$file_path = __DIR__."/access_token.txt";
chmod($file_path, 0777);
$file_lines = file($file_path);
$non_matching_lines = [];
foreach ($file_lines as $line) {
if (strpos($line, $pattern_to_match) === false) {
$non_matching_lines[] = $line;
}
}
file_put_contents($file_path, implode('', $non_matching_lines));
chmod($file_path, 0777);
}
?>