示例#1
0
 function retrieveFirstItem($uri, $idcontact_website = null)
 {
     $do_contact_website = new ContactWebsite();
     $do_contact_website->getId($idcontact_website);
     $website_type = $do_contact_website->website_type;
     if ($website_type == "RSS Feed") {
         try {
             $feed = new Zend_Feed_Rss($uri);
             $entry = $feed->current();
             if (trim($entry->title()) == trim($entry->description())) {
                 $str_item .= $entry->description() . "<br />";
             } else {
                 $str_item = "<B>" . $entry->title() . "</B><br />";
                 $str_item .= $entry->description() . "<br />";
             }
             $str_item .= " " . date("D, j M Y H:i:s", strtotime($entry->pubDate())) . "<br />";
             $arr_item[0] = $str_item;
             $arr_item[1] = strtotime($entry->pubDate());
             return $arr_item;
         } catch (Exception $ex) {
             $this->turnFeedOff($idcontact_website);
         }
     } else {
         try {
             $obj_arr_feeds = Zend_Feed::findFeeds($uri);
             foreach ($obj_arr_feeds as $channel) {
                 if ($channel->item) {
                     //fetches the first (current) updated item
                     $item = $channel->current();
                     if (trim($item->title()) == trim($item->description())) {
                         $str_item .= $item->description() . "<br />";
                     } else {
                         $str_item = "<B>" . $item->title() . "</B><br />";
                         $str_item .= $item->description() . "<br />";
                     }
                     $str_item .= " " . date("D, j M Y H:i:s", strtotime($item->pubDate())) . "<br />";
                     $arr_item[0] = $str_item;
                     $arr_item[1] = strtotime($item->pubDate());
                     break;
                 }
             }
             return $arr_item;
         } catch (Exception $ex) {
             $this->turnFeedOff($idcontact_website);
         }
     }
 }