I have built something similar so hopefully this will help get you rolling.
You are going to need to (or at least I would) create a plugin that you can call in your twig template. Pay special attention about creating a variable and services.
Let's say your plugin is called theater
.
Let's also pretend you have a url "mysite.com/showtimes"
In your showtimes
template, you would make a call to your theater plugin to get showtimes.
showtimes.twig
{# Get all upcoming showtimes from the api. #}
{% set showtimes = craft.theater.showtimes %}
I won't get into the specifics of building an entire plugin, but here are the main players you'll need.
First you'll need a file called TheaterVariable.php
that has this:
TheaterVariable.php
<?php
namespace Craft;
class TheaterVariable
{
/**
* Get all upcoming showtimes from the api.
*
* @return mixed
*/
public function showtimes()
{
$showtimes = craft()->theater->getShowTimes();
return $results['data'];
}
...
}
Now you'll need a file called TheaterService.php
to do the real work of getting your showtimes.
TheaterService.php
<?php
namespace Craft;
class TheaterService extends BaseApplicationComponent
{
/**
* Get all upcoming showtimes from the api.
*
* @return \Guzzle\Http\EntityBodyInterface|string
*/
public function getShowTimes()
{
try {
error_log((craft()->config->get('devMode')) ? 'Getting all upcoming showtimes.' . '' : '');
$client = new \Guzzle\Http\Client('http://your-api-domain.com/);
$uri = 'api/api-endpoint';
$request = $client->get($uri, array(
'content-type' => 'application/json'
));
$request->addHeader('Accept', 'application/json');
$request->addHeader('Authorization', 'YOUR CREDS');
$response = $request->send();
return $response->json();
} catch
(\Exception $e) {
if (craft()->config->get('devMode')) {
error_log('Error: Could not get upcoming showtimes.');
error_log($e->getResponse()->getBody());
}
}
...
}
}
Finally, back to your showtimes
template:
showtimes.twig
{% if showtimes|length %}
{% for showtime in showtimes %}
...
{% endfor %}
{% else %}
{# Could not find any upcoming showtimes for some reason. #}
{% endif %}
I am using oAuth to handle my authorization, so that part might be a bit different for you. But in the big picture this should be pretty close.
Hope this helps!