Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $cache = cache_get('grp_latest_news');
- if ($cache != FALSE) {
- $items = $cache->data;
- } else {
- $feed_url = 'http://www.guthrie.org/rss.xml';
- try {
- $request = drupal_http_request($feed_url);
- if ($request->code == 200) {
- $xml = simplexml_load_string($request->data);
- foreach ($xml->channel->item as $item) {
- if ($limit > 0) {
- $items[] = $item;
- }
- $limit--;
- }
- if (!empty($items)) {
- cache_set('cach', $items, 'cache', 3600);
- $items = $items;
- }
- }
- } catch (exception $e) {
- watchdog('guthrie feed', $e, array(), WATCHDOG_ERROR);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement