G. Eventbrite

  1. Authentication
  2. Events
  3. Event Search
  4. Event Set
  5. Discounts
  6. Organizer
  7. Payment
  8. Tickets
  9. User
  10. Venue

Authentication

Eventbrite only offers a personal (2-legged) or user type (3-legged) authentication. For user type authentications, the first thing we want to do is get a client ID and app secret. This can be acheived by visiting Evenbrite's Application Keys and creating a new app or using an existing one. We can next plug in both of those to start an authentication process as in Figure 1.

Figure 1. Instantiate Auth
$auth = eden('eventbrite')->auth('[CLIENT_ID]', '[APP_SECRET]', 'http://yourwebsite.com/auth');

With this auth class let's make sure we can generate a login URL. Figure 2 is used to redirect the user to twitter to continue the authentication.

Figure 2. Get Login URL
echo $auth->getLoginUrl();

When the user has authorized our app to use their data, eventbrite will add a code to the URL when it comes back to us, we can then use that to transfer to an access token. Figure 3 shows how we can convert that auth code to a token.

Figure 3. Get Token
$access = $auth->getAccess($_GET['code']);
$_SESSION['ebtoken'] = $access['access_token'];

An example of the whole entire authentication process can be found in Figure 4.

Figure 4. Authentication
//start the session
session_start();
//if code is set
if(isset($_GET['code'])) {
	//the user authorized us
	//we need to get an access token
	$access = eden('eventbrite')
		->auth('[CLIENT_ID]', '[APP_SECRET]')
		->getAccess($_GET['code']);
	
	//then save it in a session
	$_SESSION['ebtoken'] = $access['access_token'];
	
//if we do not have an access token
} else if(!isset($_SESSION['ebtoken'])) {
	//redirect to the login URL
	$url = eden('eventbrite')
		->auth('[CLIENT_ID]', '[APP_SECRET]', 'http://yourwebsite.com/auth')
		->getLoginUrl();
	
	header('Location: '.$url);
	exit;
}

© 2012 Openovate Labs. All rights reserved.