Question

I can display a list of my events using the Eventbrite PHP API and this sample events list code. This is the way the authentication is provided:

$authentication_tokens = array('app_key' => 'YOUR_APP_KEY',
                               'user_key' => 'YOUR_USER_KEY');

I understand from the Eventbrite documentation that you can refine the list to only show public events by not providing authentication tokens. However if I exclude:

,'user_key' => 'YOUR_USER_KEY' 

I receive the following error message:

Fatal error: Uncaught exception 'Exception' with message 'Invalid email address . [None]'.... 

Could anyone please suggest how to only show eventbrite public events by not providing authentication tokens?

Thanks in advance,

Était-ce utile?

La solution

The API call you are using looks up event by user:

http://developer.eventbrite.com/doc/users/user_list_events/

By not supplying a user_key or user field (which is the email of the user), it doesn't really make sense.

If you'd like to get a listing of public events, you can use the event_search API:

http://developer.eventbrite.com/doc/events/event_search/

curl http://www.eventbrite.com/json/event_search -G -d app_key=$EB_APP_KEY

All of the fields are optional, so by leaving everything out, you effectively get a listing of public events.

Autres conseils

For Anyone else wanting to achieve the same thing I thought I'd list some sample code:

<!DOCTYPE HTML>
<html>
<head>
  <title>Eventbrite</title>

 <meta charset="UTF-8">

 </head>
 <body>

 <?php
 // load the API Client library
 include "eventbrite.php";

 // Initialize the API client
 // Eventbrite API / Application key (REQUIRED)
 // http://www.eventbrite.com/api/key/
 // Eventbrite user_key (OPTIONAL, only needed for reading/writing private user data)
 // http://www.eventbrite.com/userkeyapi
 $authentication_tokens = array('app_key' => 'YOURAPPKEYGOESHERE',
                                'user_key' => 'YOURUSERKEYGOESHERE');
 $eb_client = new Eventbrite( $authentication_tokens );

 // For more information about the features that are available through the Eventbrite API, see      http://developer.eventbrite.com/doc/
 // $events = $eb_client->user_list_events();

 $search_params = array(
     'organizer' => 'YOURORGANISERNAMEGOESHERE',
     'sort_by' => 'date',
 );
 $resp = $eb_client->event_search( $search_params );

 //mark-up the list of events that were requested
 // render in html - ?>
 <style type="text/css">
 .eb_event_list_item{
   padding-top: 20px;
 }
 .eb_event_list_title{
   position: absolute;
   left: 300px;
   width: 300px;
   overflow: hidden;
 }
 .eb_event_list_date{
   padding-left: 20px;
 }
 .eb_event_list_time{
   position: absolute;
   left: 200px;
 }
 .eb_event_list_location{
   position: absolute;
   left: 620px;
 }
 </style>

 <h1>My Event List:</h1>
 <?= Eventbrite::eventList( $resp, 'eventListRow'); ?>  

 </body>
 </html>

If you want to change how the data is returned you edit the eventbrite.php page. eg I wanted to include the year in the date so I edited line 258 changing strftime to

 strftime('%a, %e, %B, %Y', $time)

Hope this helps someone :)

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top