0.1.1 • Published 9 years ago

eventbrite-node v0.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

#eventbrite-node v0.1.0

eventbrite-node is Eventbrite API client for node.js.

##Installation

$ npm install --save eventbrite-node

##Configuration

    var Eventbrite = require('eventbrite-node');
    var client = new Eventbrite(YOUR-CLIENT-KEY, YOUR-CLIENT-SECRET);

##Authentication

If you have an access token from other module you can set it directly:

client.setAccessToken(YOUR-ACCESS-TOKEN);

otherwise you have to get it and you can do it with eventbrite-node

	// first you have to redirect user to authorization p
	var authUrl = client.getOAuthUrl();
	res.redirect(authUrl);

	// next, you retrive code from query string and exchange it for access token
	client.authorize(req.query.code, function(err, response) {
		if(err) {
			console.log.error(err);
			return;
		}
		console.log(response.access_token);
	});

##API calls

If you have correct access token, you can make api calls

	client.get('/users/me', function(err, response) {
		if(err) {
			console.error(err);
			return;
		}
		console.log(response);
	});

or POST request

	client.post('/users/1/contact_lists', { name: 'Last Event Attendees' }, function(err, response) {
		if(err) {
			console.error(err);
			return;
       	}
		console.log(response);
	});

##Promises

If you prefer promises you can use them

	client.authorize(req.query.code)
		.then(function(response) {

	    })
	    .catch(function(error) {

	    });

	client.get('/users/me').then(function(response) {
		//......
	});

	client.post('/users/1/contact_lists', {}).then(function(response) {
   		//......
    });
0.1.1

9 years ago

0.1.0

9 years ago