EventBrite and AgFx – Windows Phone development

So you will already know that anything linked to online data should be retrieved using AgFx! Now if you have that, let me show you how you can use this for retrieving event data from EventBrite ( an online service to host an event calendar and maintain attendees data ).

EventBrite is a cool online service that also comes packed with a great API that will allow devs to integrate it in their own apps.

Before I continue I must point out that there is also a clean .net wrapper available, called EventBrite.Net but like I stated above, I’m more hooked on AgFx so I didn’t used the wrapper.

Before you can do anything with the EventBrite API you first should get an API key through their website here… After that you are set to go! With that API key you can than start using all API methods that are described on the EventBrite API documentation here…

For this demo we will try to download a list of events for a given organizer, the API method to get this info is organizer_list_events. But before we can do anything in our program we need to have .net objects representing the EventBrite response. Getting this information is not that difficult… First find an organizer and get it’s ID. You’ll only need to get the list of all events given by the organizer and EventBrite will show you his ID in the URL: I used this one http://www.eventbrite.com/org/2276332563 so the ID here is 2276332563

With this, you can use Fiddler to take a look at the returning JSON result. Open the composer tab in Fiddler and paste a legal EventBrite API method URL in the GET input box: https://www.eventbrite.com/json/organizer_list_events?app_key=[YOUR KEY HERE]&id=2276332563
When everything is ok, you’ll get a big JSON result back that contains all event information. This result will help you getting the needed .net objects! In Fiddler open the Raw tab in the Response pane and only copy the JSON string… after you have copied that, use a word processing tool to strip it of all unneeded line returns ( ex: Notepad++ with TextFX plugin – Unwrap text ). With your currently stripped JSON response go to the fantastic site called json2csharp! Paste your JSON code and press the Generate button, when all goes well you’ll get following result:

Or you can just copy it from my blog post Winking smile

DO NOTE that not it seems that not all JSON names are .net compatible resulting in _invalid_name_ prefixes! My suggestion is to change the .net class and ‘manipulate’ the JSON mapping in your app! ( I’m NOT covering this in the rest of the example )

So you added these classes in some Model part of your project, next up hooking up AgFx to EventBrite. To get this working you’ll need to create an AgFx ‘viewmodel’, here is how I did it:

A lot of code, but if you are used to working with AgFx, most of it will look familiar… The only ‘special’ thing is being done inside the GetLoadRequest method, here we need to give AgFx our API method URL. So I just wrapped all possible methods inside a static class EventBriteAPI. But in the end all it does is generate the same URL we used in Fiddler being: https://www.eventbrite.com/json/organizer_list_events?app_key=[YOUR KEY HERE]&id=2276332563

So that’s it, now you will have all events retrieved from EventBrite through AgFx! Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *