message, "\n"; } exit(1); } foreach($sxe->entry as $entry) { $id = $entry->id; $title = $entry->title; $published = $entry->published; $updated = $entry->updated; if($updated == NULL) { $updated = $published; } $updated = DateTime::createFromFormat($format, $updated, $timezone); # echo "updated=" . $updated->format($format) . "\n"; if(!isset($id)) { echo "Invalid atom entry, missing from ."; continue; } if($updated === FALSE) { echo "Invalid atom entry, missing/invalid or from ."; continue; } if($state != NULL && $state >= $updated) { # echo "old entry: $id\n"; continue; } echo "New entry: $id\n"; if($newest == NULL || $newest < $updated) { $newest = $updated; } $entry_file = tmpfile() or exit("Unable to open temporary file"); fwrite($entry_file, $entry->asXML()) or exit("Unable to write xml");; fseek($entry_file, 0); $curl = curl_init() or exit("Unable to allocate cURL object"); curl_setopt($curl, CURLOPT_URL, $queue); # curl_setopt($curl, CURLOPT_VERBOSE, TRUE); curl_setopt($curl, CURLOPT_INFILE, $entry_file); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/atom+xml;type=entry", "trygve: kul")); curl_exec($curl) or exit("Error while executing cURL"); // if success, pick out Location headers. fclose($entry_file); curl_close($curl); } if(isset($newest)) { file_put_contents($state_file, $newest->format($format) . "\n"); } ?>