Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getTwitter() {
- $filename = "tweets";
- $useCache = false;
- $cache = "";
- if (file_exists('_temp/' . $filename . '.json')) {
- $time = file_get_contents('_temp/' . $filename . '.time');
- if (time() - $time > 15 * 60) {
- $useCache = false;
- }
- else {
- $cache = file_get_contents('_temp/' . $filename . '.json');
- $useCache = true;
- }
- }
- if ($useCache) {
- $data = $cache;
- }
- else {
- $data = getTimeline();
- file_put_contents('_temp/' . $filename . '.json', $data);
- file_put_contents('_temp/' . $filename . '.time', time());
- }
- $tweets = json_decode($data);
- $tarray = array();
- $i = 0;
- foreach($tweets as $t) {
- $tarray[$i]['text'] = parseTweet($t->text);
- $tarray[$i]['daysago'] = daysAgo(strtotime($t->created_at));
- $i++;
- }
- return $tarray;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement