-
-
Notifications
You must be signed in to change notification settings - Fork 227
/
tag_all_friend_FB.php
62 lines (62 loc) · 2 KB
/
tag_all_friend_FB.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
58
59
60
61
62
<?php
ini_set('max_execution_time', 0);
$post_id = "";//id bài muốn bình luận
$token = "";//token của bạn
$text = ""; //điền vào đây lời nhắn bạn muốn gửi
$array_avoid = ["100003219300242","100001518861027","100004053704354","100001914300875","100000217222833"]; //điền id những bạn mà bạn không muốn tag vào
$url = "https://graph.facebook.com/me/friends?limit=5000&fields=id&access_token=$token";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "$url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 0,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false
));
$response = curl_exec($curl);
curl_close($curl);
$data = json_decode($response,JSON_UNESCAPED_UNICODE);
$datas = $data["data"];
$message = "";
$dem = 0;
foreach($datas as $each){
$message .= "@[".$each["id"].":0] ";
$dem++;
if(in_array($each["id"], $array_avoid)) {
continue;
}
//cứ 5 bạn thì sẽ tag 1 lần, tránh bị FB hiểu nhầm spam, và sẽ tự động tag mỗi 10 giây cho đến hết danh sách
if($dem == 5){
$message .= "
$text";
$curl = curl_init();
$message = curl_escape($curl,$message);
$url = "https://graph.facebook.com/$post_id/comments?method=post&message=$message&access_token=$token";
curl_setopt_array($curl, array(
CURLOPT_URL => "$url",
CURLOPT_RETURNTRANSFER => false,
CURLOPT_TIMEOUT => 0,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false
));
curl_exec($curl);
curl_close($curl);
$dem=0;
sleep(10);
$message = "";
}
}
$message .= "
$text";
$curl = curl_init();
$message = curl_escape($curl,$message);
$url = "https://graph.facebook.com/$post_id/comments?method=post&message=$message&access_token=$token";
curl_setopt_array($curl, array(
CURLOPT_URL => "$url",
CURLOPT_RETURNTRANSFER => false,
CURLOPT_TIMEOUT => 0,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false
));
curl_exec($curl);
curl_close($curl);