Skip to content

Instantly share code, notes, and snippets.

@jsmitka
Created February 3, 2012 21:16
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 jsmitka/1732668 to your computer and use it in GitHub Desktop.
Save jsmitka/1732668 to your computer and use it in GitHub Desktop.
<?php
if (!isset($cache['data'])) {
$params = \Nette\Environment::getConfig('facebook');
$fb = new \Facebook(array(
'appId' => $params->appId,
'secret' => $params->secret
));
$data = $fb->api('/' . $this->objId . '/feed&limit=3');
$data = $data['data'];
$pdt = new \DateTimeZone('PST8PDT');
$us = new \DateTimeZone('GMT');
foreach ($data as $i => $item) {
if (isset($item['properties'])) {
if($date = \DateTime::createFromFormat('l, F j, Y * G:ia', $item['properties'][0]['text'], $us)) {
$date->setTimezone($pdt);
$data[$i]['properties'][0]['text'] = $date;
}
}
}
$cache->save('data', $data, array(
Cache::EXPIRE => '+ 10 minutes'
));
$cache->save('object', $fb->api('/' . $this->objId), array(
Cache::EXPIRE => '+ 10 minutes'
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment