Last active
August 29, 2015 14:19
-
-
Save jessefulton/b6902ea09970f130ce5a to your computer and use it in GitHub Desktop.
Create test users for a Facebook application
This file contains 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
#!/usr/bin/env node | |
// | |
// usage: | |
// FACEBOOK_APP_ID=<APPID> FACEBOOK_APP_SECRET=<SECRET> ./test/load-test/scripts/facebook/create-test-users.js > output.csv | |
// | |
var userCount = process.env.USER_COUNT || 10; | |
var restify = require("restify") | |
async = require("async"); | |
var BASE_URL = "https://graph.facebook.com"; | |
var fbClient = restify.createJsonClient({ | |
url: BASE_URL, | |
version: '*' | |
}); | |
setTimeout(function() { | |
async.timesSeries(userCount, function(n, next) { | |
fbClient.get("/oauth/access_token?client_id=" + process.env.FACEBOOK_APP_ID + "&client_secret=" + process.env.FACEBOOK_APP_SECRET + "&grant_type=client_credentials", function(e, rq, rs, o) { | |
if (e) { | |
return next(e); | |
} | |
fbClient.post("/" + process.env.FACEBOOK_APP_ID + "/accounts/test-users?" + rs.body, {installed:true}, function(err, req, res, obj) { | |
if (err) { | |
return next(err); | |
} | |
next(null, obj); | |
}); | |
}); | |
}, function(err, results) { | |
if (err) { | |
console.error(err); | |
process.exit(1); | |
} | |
console.log("email,password"); | |
results.forEach(function(obj) { | |
console.log([obj.email, obj.password].join(',')); | |
}); | |
process.exit(0); | |
}); | |
}, 1000); |
This file contains 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
{ | |
"engines": { | |
"node": "0.10.36", | |
"npm": "2.6.1" | |
}, | |
"dependencies": { | |
"restify": "2.8.5", | |
"async": "0.9.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment