Skip to content

Instantly share code, notes, and snippets.

@hdknr
Created October 18, 2009 19:07
Show Gist options
  • Save hdknr/212798 to your computer and use it in GitHub Desktop.
Save hdknr/212798 to your computer and use it in GitHub Desktop.
function _response_to_rss ($resp) {
$rss = new MagpieRSS( $resp->results );
// if RSS parsed successfully
if ( $rss && (!isset($rss->ERROR) || !$rss->ERROR) ) {
// find Etag, and Last-Modified
foreach( (array) $resp->headers as $h) {
// 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1"
if (strpos($h, ": ")) {
list($field, $val) = explode(": ", $h, 2);
}
else {
$field = $h;
$val = "";
}
if ( $field == 'ETag' ) {
$rss->etag = $val;
}
if ( $field == 'Last-Modified' ) {
$rss->last_modified = $val;
}
}
return $rss;
} // else construct error message
else {
$errormsg = "Failed to parse RSS file.";
if ($rss) {
$errormsg .= " (" . $rss->ERROR . ")";
}
// error($errormsg);
return false;
} // end if ($rss and !$rss->error)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment