Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module.exports.sendCampaign = function() {
- getGroupUsers(1407520159508452);
- }
- function getGroupUsers(id) {
- var token = process.env.FACEBOOK_TOKEN;
- var url = 'https://graph.facebook.com/v2.6/' + id + '/members?access_token=' + token;
- var list = [];
- getGroupData(url, function(users, next) {
- users.map(function(user) {
- list.push(user.id);
- });
- if (next) {
- getGroupData(next);
- } else {
- return list;
- }
- });
- }
- function getGroupData(url, cb) {
- request(url, function(err, http, body) {
- if (!err && http.statusCode == 200) {
- var body = JSON.parse(body);
- var users = body.data;
- var next = body.paging.next;
- cb(users, next);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement