You are here

function _facebook_pull_feed_cached in Facebook Pull 6

Same name and namespace in other branches
  1. 7.3 facebook_pull.module \_facebook_pull_feed_cached()
  2. 7 facebook_pull.module \_facebook_pull_feed_cached()
  3. 7.2 facebook_pull.module \_facebook_pull_feed_cached()

Pull data from a facebook feed and cache it

1 call to _facebook_pull_feed_cached()
facebook_pull_render in ./facebook_pull.module
Serve up a facebook feed from the cache

File

./facebook_pull.module, line 239

Code

function _facebook_pull_feed_cached($graph_id, $type, $app_id, $app_secret, $options = array()) {
  $cache_key = sprintf("%s-%s-%s", $graph_id, $type, http_build_query($options, '', '-'));
  $cache = cache_get($cache_key);
  if (!$cache || $cache->created + FACEBOOK_PULL_CACHETIME < time()) {
    $token = _facebook_pull_accesstoken($app_id, $app_secret);
    $data = _facebook_pull_feed($graph_id, $type, $token, $options);
    cache_set($cache_key, $data, 'cache', CACHE_TEMPORARY);
  }
  else {
    $data = $cache->data;
  }
  return $data;
}