forked from dev-black/facebook-tools-simple
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove-adaccounts-no-payment.html
93 lines (90 loc) · 3.88 KB
/
remove-adaccounts-no-payment.html
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Document</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">
</head>
<body style="padding-top: 50px;">
<div class="container">
<div class="panel panel-primary">
<div class="panel-heading">Đá tài khoản quảng cáo chưa có payment</div>
<div class="panel-body">
<input id="access_token" class="form-control" placeholder="Nhập Access Token ...">
<div class="col-md-12 text-center" style="font-size: 50px;">
<div class="col-md-6" style="color: green" id="success">0</div>
<div class="col-md-6" style="color: red" id="error">0</div>
</div>
</div>
<div class="panel-footer">
<div class="text-center">
<button class="btn btn-primary" id="submit" data-loading-text="Đang gửi ...">Bắt đầu</button>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function($) {
var access_token, success, error, user_id;
$("#submit").click(function() {
access_token = $("#access_token").val().trim();
success = 0;
error = 0;
$("#submit").button('loading');
$.get('https://graph.facebook.com/me', {
access_token: access_token
}).done(function(e) {
user_id = e.id;
run_script();
}).error(function() {
$("#submit").button('reset');
alert('Access Token không hợp lệ !');
});
});
function run_script() {
var inLoop = 0;
$.get('https://graph.facebook.com/v2.8/me/adaccounts', {
fields: 'all_payment_methods{payment_method_altpays{account_id,country,credential_id,display_name,image_url,instrument_type,network_id,payment_provider,title},pm_credit_card{account_id,credential_id,credit_card_address,credit_card_type,display_string,exp_month,exp_year,first_name,is_verified,last_name,middle_name,time_created},non_ads_credit_card{account_id,credential_id,credit_card_address,credit_card_type,display_string,exp_month,exp_year,first_name,is_verified,last_name,middle_name,subtitle,time_created},payment_method_direct_debits{account_id,address,can_verify,credential_id,display_string,first_name,is_awaiting,is_pending,last_name,middle_name,status,time_created},payment_method_extended_credits{account_id,balance,credential_id,max_balance,type,partitioned_from,sequential_liability_amount},payment_method_paypal{account_id,credential_id,email_address,time_created},payment_method_stored_balances{account_id,balance,credential_id,total_fundings},payment_method_tokens{account_id,credential_id,current_balance,original_balance,time_created,time_expire,type}}',
limit: '1000',
access_token: access_token
}).done(function(e) {
e.data.forEach(function(item) {
if (!item.all_payment_methods) {
remove_uid(item.id, function(status) {
++inLoop;
if (status) {
$("#success").text(~~$("#success").text() + 1);
} else {
$("#error").text(~~$("#error").text() + 1);
}
if (inLoop == e.data.length) {
setTimeout(function() {
run_script();
}, 3000);
}
});
}
});
}).error(function() {
run_script();
})
}
function remove_uid(account_id, callback) {
$.get("https://graph.facebook.com/v2.8/" + account_id + "/users/" + user_id, {
method: 'delete',
access_token: access_token
}).done(function() {
callback(true);
}).error(function() {
callback(false);
});
}
});
</script>
</body>
</html>