Skip to content

Instantly share code, notes, and snippets.

@mharsch
Created February 25, 2012 23:57
Show Gist options
  • Save mharsch/1911743 to your computer and use it in GitHub Desktop.
Save mharsch/1911743 to your computer and use it in GitHub Desktop.
Create a facebook test user using node.js
var qs = require('querystring');
var request = require('request');
var app_id = '<your_fb_app_id>';
var app_secret = '<your_fb_app_secret>';
var app_login_url = 'https://graph.facebook.com/oauth/access_token'
var app_login_qs = {
client_id: app_id,
client_secret: app_secret,
grant_type: 'client_credentials'
};
// Obtain App Access Token
request.get({url: app_login_url, qs:app_login_qs}, function (e, r, body) {
if (!e && r.statusCode == 200) {
var app_token = qs.parse(body).access_token;
var create_user_url = 'https://graph.facebook.com/' + app_id + '/accounts/test-users'
var create_user_qs = {
installed: 'true',
name: 'test user',
permissions: 'read_stream,publish_stream,offline_access,sms',
access_token: app_token
}
// Create Test User
request.post({url: create_user_url, qs: create_user_qs}, function (e, r, body) {
if (!e && r.statusCode == 200) {
console.log(body);
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment