Broadcast on Broadcast off
The Documentation for Project Zero has moved. Please update your bookmarks to: http://www.projectzero.org/documentation/
Table of
Contents...
Hide
 

Atom handling in PHP

The PHP environment supports Atom by leveraging the Project Zero support for Atom. Please see the Core Atom Developers Guide for information about the underlying library.

Enabling Atom

To enable Atom support, add the following dependencies to the ivy.xml file.

zero.php
zero.atom

Atom renderer

The following code samples demonstrate the rendering of Atom entry and feed documents. Notice that two distinct types of date values are accepted in the updated field.

  1. Timestamp : This is a numeric value representing the number of milliseconds since the Unix epoch, which is defined as January 1 1970 00:00:00 GMT. Note that the time() function returns the number of seconds since the epoch.
  2. Date String : This is a string value representing a date. Acceptable values may include the date only ("1970-01-01") or the date and time ("1980-12-25 12:00:00"). For millisecond resolution, the Timestamp format should be used.

Atom entry document

<?php
$entry = array(
"id" => 1,
"title" => "A Good Title is Important",
"authorname" => "John Doe",
"updated" => time() * 1000, // milliseconds since the epoch
"contenttype" => "TEXT",
"content" => "Content is also important."
);

zput("/request/view","atom");
zput("/request/atom/output",$entry);
render_view();
?>

Atom feed document

<?php

// Rendering an Atom feed document.

$feed = array(
array(
"id" => 1,
"title" => "A Good Title is Important",
"authorname" => "John Doe",
"updated" => "1970-01-01", // date format
"contenttype" => "TEXT",
"content" => "Content is also important."
),
array(
"id" => 2,
"title" => "Bad Titles are Misleading",
"authorname" => "Jane Q. Sample",
"updated" => "1980-12-25 12:00:00", // date time format
"contenttype" => "TEXT",
"content" => "Content is also important."
)
);

zput("/request/view","atom");
zput("/request/atom/output",$feed);
render_view();

?>

r4 - 08 Nov 2007 - 20:03:13 - madhu
Syndicate this site RSS ATOM
Copyright 2007 © IBM Corporation | Privacy | Terms of Use | About this site