Assembla home | Assembla project page
 

Changeset 104

Show
Ignore:
Timestamp:
03/02/08 19:55:58 (9 months ago)
Author:
tobias382
Message:

* Added a user agent to FeedTicker?'s file_get_contents call so requests to sites that require it don't fail
* Fixed an issue in FeedTicker? where a failed feed retrieval attempt could cause old items to be syndicated

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Phergie/Plugin/FeedTicker.php

    r87 r104  
    144144        $retrieved = array(); 
    145145 
     146        $context = stream_context_create(array('http' => array( 
     147            'timeout' => 5, 
     148            'user_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9b3) Gecko/2008020514 Firefox/3.0b3' 
     149        ))); 
     150 
    146151        // Retrieve each feed 
    147152        foreach ($this->feeds as $id => $feed) { 
    148153            list ($url, $chans) = $feed; 
    149154 
    150             $content = file_get_contents($url); 
     155            $content = @file_get_contents($url, null, $context); 
    151156            if (empty ($content)) { 
     157                $this->debug('Feed empty: ' . $url);  
    152158                continue; 
    153159            } 
     
    167173                } 
    168174            } else { // Trouble 
    169                 continue; 
     175                $this->debug('Feed format unrecognized: ' . $url); 
     176                continue;  
    170177            } 
    171178        } 
     
    192199                } 
    193200            } 
    194         } 
    195         // Cache current data for next run 
    196         $this->cache = $retrieved; 
     201            // Cache current data for next run 
     202            $this->cache[$id] = $articles; 
     203        } 
    197204    } 
    198205