Skip to content

Instantly share code, notes, and snippets.

@shalintripathi
Forked from haugstrup/podio-redis.php
Last active August 29, 2015 14:13
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 shalintripathi/6132cfdab3526e810748 to your computer and use it in GitHub Desktop.
Save shalintripathi/6132cfdab3526e810748 to your computer and use it in GitHub Desktop.
<?php
// Setup Podio Client
Podio::setup(CLIENT_ID, CLIENT_SECRET);
// Setup Redis
$redis = new Predis\Client(REDIS_INFO)
$my_cache_key = "podio_cache";
if ($redis->exists($my_cache_key)) {
// We have a cached copy, use that
$my_data = $redis->get($my_cache_key);
}
else {
// No cache or cache expired, contact Podio
// Authenticate as an app
Podio::authenticate('app', array('app_id' => APP_ID, 'app_token' => APP_TOKEN));
// Get a single item
$item = PodioItem::get(ITEM_ID);
// Find the value of the 'title' field
$my_data = $item->fields['title']->values;
// Store in cache
$redis->set($my_cache_key, $my_data);
$redis->expire($my_cache_key, 60*60*12); // Expire in 12 hours
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment