Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 68 lines (59 sloc) 2.204 kb
23e0dd63 »
2011-10-14 adding a sorted attendee list example
1 <?php
2 // load the API Client library
3 include "../Eventbrite.php";
4
5 // Initialize the API client
6 // Eventbrite API / Application key (REQUIRED)
7 // http://www.eventbrite.com/api/key/
8 // Eventbrite user_key (OPTIONAL, only needed for reading/writing private user data)
9 // http://www.eventbrite.com/userkeyapi
10 $authentication_tokens = array('app_key' => 'YOUR_APP_KEY',
11 'user_key' => 'YOUR_USER_KEY');
12 $eb_client = new Eventbrite( $authentication_tokens );
13
14 try{
15 // For more information about the functions that are available through the Eventbrite API, see http://developer.eventbrite.com/doc/
16 $attendees = $eb_client->event_list_attendees( array('id'=>'YOUR_EVENT_ID') );
17 } catch ( Exception $e ) {
18 // Be sure to plan for potential error cases
19 // so that your application can respond appropriately
20
21 //var_dump($e);
22 $attendees = array();
23 }
24
25 function attendee_to_html( $attendee ){
26 if($attendee->first_name){
27 return "<div class='eb_attendee_list_item'>".$attendee->first_name.' '.$attendee->last_name."</div>\n";
28 }else{
29 return '';
30 }
31 }
32
33 function sort_attendees_by_created_date( $x, $y ){
34 if($x->attendee->created == $y->attendee->created ){
35 return 0;
36 }
37 return ( $x->attendee->created > $y->attendee->created ) ? -1 : 1;
38 }
39
40 function attendee_list_to_html( $attendees ){
41 $attendee_list_html = "<div class='eb_attendee_list'>\n";
42 if( isset($attendees->attendees) ){
43 //sort the attendee list?
44 usort( $attendees->attendees, "sort_attendees_by_created_date");
45 //render the attendee as HTML
46 foreach( $attendees->attendees as $attendee ){
47 $attendee_list_html .= attendee_to_html( $attendee->attendee );
48 }
49 }else{
50 $attendee_list_html .= '<div class="eb_attendee_list_item">You can be the first to register for this event!</div>';
51 }
52 return $attendee_list_html . "</div>\n";
53 }
54
55 //mark-up your attendee list
56 // render in html - ?>
57 <style type="text/css">
58 .eb_attendee_list_item{
59 padding-bottom: 8px;
60 }
61 .eb_attendee_list{
62 margin-left: 20px;
63 }
64 </style>
65
66 <h1>Event Attendee List:</h1>
67 <?= attendee_list_to_html( $attendees ); ?>
Something went wrong with that request. Please try again.