Skip to content

Instantly share code, notes, and snippets.

@matherton
Created September 27, 2011 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matherton/1245090 to your computer and use it in GitHub Desktop.
Save matherton/1245090 to your computer and use it in GitHub Desktop.
First event creation form using the Eventbrite class
<?php
/*This script does the following:
1. Loads the eventbrite client library
2. Get all variables form form
3. Puts my eventbrite account details into an array
4. Gets the submitted data and puts into an array
5. Passes data to API to create event
6. Recieve a confomation ticket of newly created event*/
// load the API Client library
include "eventbrite.php";
// Mandatory hard coded data
$country_code = 'GB';
$timezone = 'GMT+00';
$organizer_id = '1487912990';
// Get the mandatory variables from the form
$title = $_POST['title'];
$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];
// Get optional fields drom the form if there are any
$description = $_POST['description'];
$privacy = $_POST['privacy'];
$personalized_url = $_POST['personalized_url'];
$venue_id = $_POST['venue_id'];
$capacity = $_POST['capacity'];
//hardcoded optional fields
$organizer_id = '1487912990';
//print "$organizer_id<br />";
print "$country_code<br />";
print "$timezone<br />";
print "$title<br />";
print "$start_date<br />";
print "$end_date<br />";
print "$description<br />";
print "$privacy<br />";
print "$venue_id<br />";
print "$capacity<br />";
// initialise the API client with my credentials putting them into an array
$authentication_tokens = array('app_key' => 'YOUR APP KEY IN HERE',
'user_key' => 'YOUR USER KEY IN HERE');
$eb_client = new Eventbrite($authentication_tokens);
// Put form data into an array
$resp = $eb_client->event_new(array("organizer_id"=>$organizer_id,
"title"=>$title,
"start_date"=>$start_date,
"end_date"=>$end_date,
"country_code"=>$country_code,
"timezone"=>$timezone,
"privacy"=>$privacy,
"description"=>$description,
"personalized_url"=>$personalized_url,
"venue_id"=>$venue_id, does not work until create with venue_new method
"capacity"=>$capacity
)
);
/**/
// Get entire returned ticket from event brite and store as $str
$str = serialize($resp);
// Extract just the id from the eventbrite ticket
$refined_str = stristr($str, 'id');
$event_id = mb_substr($refined_str, 6, 10, 'UTF-8');
echo "Your event ID is $event_id \n<br />";
?>
<html>
<header>
<title>The Stage - Event update form</title>
</header>
<body>
<!-- A form to create an event and post it's variables to update.php once submitted -->
<form method="post" action="update.php">
<fieldset>
<legend>Enter event details <strong>(mandatory)</strong></legend>
<ol>
<li><label for="title">Enter event title: </label><input name="title" id="title" title="type the title of your event" type="text" placeholder="255 characters max"></li>
<li><label for="start_date">Enter start date+time: </label><input name="start_date" id="start_date" title="type the start time and date of you event in the following format yyyy-month-day+time" type="text" placeholder="2011-12-31 10:00:00"></li>
<li><label for="end_date">Enter end date+time: </label><input name="end_date" id="end_date" title="type the end time and date of you event in the following format yyyy-month-day+time" type="text" placeholder="2012-01-01 02:00:00"></li>
</ol>
</fieldset>
<fieldset>
<!-- This need to match up with whether the wordpress post has been published or in a live status -->
<legend>Enter event details <strong>(optional)</strong></legend>
<select name="privacy">
<option value="">event status?</option>
<option value="1">Live</option>
<option value="0">Draft</option>
</select>
<label for="description">Description:</label><textarea name="description" id="description" rows="5" placeholder="Please enter a description of your event"></textarea>
<label for "personalized_url">Event registration URL</label><input name="personalized_url" id="personalized_url" type="text" placeholder="'your entry'.eventbrite.com">
<br />
<br />
<!-- This needs to be populated from venues already created from WP Database -->
<select name="venue_id">
<option value="">Select venue?</option>
<option value="1">Venue 1 form WP DB</option>
<option value="2">Venue 2 from WP DB</option>
<option value="3">Venue 3 from WP DB</option>
</select>
<!-- This should link up with ticket numbers -->
<label for="capacity">Venue Capacity: </label><input name="capacity" id="capacity" title="type the capacity of your event" type="text" placeholder="maximum venue capacity">
<input type="submit" name="submit" value="submit form">
</legend>
</fieldset>
</form>
</body>
</html>
@matherton
Copy link
Author

The event bright API requires you to create data in a particular order:

  1. First you need to create an organisation and save the ID
  2. Then you can create a venue using the ID of the organisation. Once you have created a venue successfully you will get back a venue ID which you need to save.
  3. With the Venue ID you can create a new event by using the form above.

Takes a bit to work this out but hopefully I have explained it well enough so you won't need to work this out for yourself - ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment