<docbook><section><title>ODSProgrammersGuideOpenSocial</title><para> </para>
<title> OpenSocial API support</title> <ulink url="OpenSocial">OpenSocial</ulink> API support
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> APIs supported</bridgehead>
<para>The ODS package contains <ulink url="OpenSocial">OpenSocial</ulink> data APIs about people and activities.
 Also it implements a login compatible with GBase which can be used to perform <ulink url="OpenSocial">OpenSocial</ulink> API calls requiring authentication.
 The implementation code is located in the opensocial.sql file from the ods package.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> Authentication</bridgehead>
<para>The authentication is compatible with GBase ClientLogin username/password authentication.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> REST API details</bridgehead>
 <itemizedlist mark="bullet" spacing="compact"><listitem>URI: http://&lt;cname&gt;:&lt;port&gt;/feeds/login</listitem>
</itemizedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3">Parameters</bridgehead>
 <itemizedlist mark="bullet" spacing="compact"><listitem>Uname - the ODS user account </listitem>
<listitem>Passwd - password</listitem>
</itemizedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3">Return</bridgehead>
<itemizedlist mark="bullet" spacing="compact"><listitem>On success it will return: <programlisting>auth=NNNN 
</programlisting>where NNNN...
 is a security token and it matches a SID for login to ODS.</listitem>
</itemizedlist><itemizedlist mark="bullet" spacing="compact"><listitem>If authentication fails it will return: <programlisting>Error=BadAuthentication
</programlisting> </listitem>
</itemizedlist><bridgehead class="http://www.w3.org/1999/xhtml:h3"> Sample session</bridgehead>
<programlisting>$ curl -i &quot;http://localhost/feeds/login?Uname=test&amp;Passwd=secret&quot;
HTTP/1.1 200 OK
Server: Virtuoso/05.00.3021 (Linux) i686-pc-linux-gnu  VDB
Connection: Keep-Alive
Date: Wed, 14 Nov 2007 16:44:42 GMT
Accept-Ranges: bytes
Content-Type: text/plain; charset=&quot;ISO-8859-1&quot;
Content-Length: 38

auth=f305177cb1d9fbf409579250e944e980
</programlisting><bridgehead class="http://www.w3.org/1999/xhtml:h2"> People API</bridgehead>
<para>The people API is implemented as described in <ulink url="http://code.google.com/apis/opensocial/docs/gdata/people/developers_guide_protocol.html">http://code.google.com/apis/opensocial/docs/gdata/people/developers_guide_protocol.html</ulink> The only difference is that personID is not a number but ODS user account.</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> Sample Session</bridgehead>
<bridgehead class="http://www.w3.org/1999/xhtml:h4"> Person data</bridgehead>
 <programlisting>$ curl -i &quot;http://localhost:8890/feeds/people/demo&quot;
HTTP/1.1 200 OK
Server: Virtuoso/05.00.3021 (Linux) i686-pc-linux-gnu  VDB
Connection: Keep-Alive
Date: Wed, 14 Nov 2007 16:49:27 GMT
Accept-Ranges: bytes
Content-Type: application/atom+xml; charset=&quot;ISO-8859-1&quot;
Content-Length: 1018

&lt;entry xmlns=&quot;http://www.w3.org/2005/Atom&quot; xmlns:georss=&quot;http://www.georss.org/georss&quot; xmlns:gd=&quot;http://schemas.google.com/g/2005&quot;&gt;
&lt;id&gt;http://localhost:8890/feeds/people/demo&lt;/id&gt;
&lt;updated&gt;2007-11-01T10:55:33.000+02:00&lt;/updated&gt;
&lt;title&gt;demo demo&lt;/title&gt;
&lt;link rel=&quot;thumbnail&quot; type=&quot;image/*&quot; href=&quot;/DAV/home/demo/wa/images/me_avt.jpg&quot;/&gt;
&lt;link rel=&quot;alternate&quot; type=&quot;text/html&quot; href=&quot;http://localhost:8890/dataspace/person/demo&quot;/&gt;
&lt;link rel=&quot;self&quot; type=&quot;application/atom+xml&quot; href=&quot;http://localhost:8890/feeds/people/demo&quot;/&gt;
&lt;georss:where&gt;
&lt;gml:Point xmlns:gml=&quot;http://www.opengis.net/gml&quot;&gt;
&lt;gml:pos&gt;43.000000 25.000000&lt;/gml:pos&gt;
&lt;/gml:Point&gt;
&lt;/georss:where&gt;
&lt;gd:extendedProperty name=&quot;lang&quot; value=&quot;en-US&quot;/&gt;
&lt;gd:postalAddress label=&quot;Home&quot;&gt;&lt;![CDATA[
str. 123
apt. 45
New York
USA
]]&gt;&lt;/gd:postalAddress&gt;
&lt;gd:postalAddress label=&quot;Work&quot;&gt;&lt;![CDATA[
]]&gt;&lt;/gd:postalAddress&gt;
&lt;gd:phoneNumber label=&quot;Private&quot; rel=&quot;http://schemas.google.com/g/2005#mobile&quot;&gt;+359887563204&lt;/gd:phoneNumber&gt;
&lt;/entry&gt;
</programlisting><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h4"> Friends</bridgehead>
 <programlisting>$ curl -i &quot;http://localhost:8890/feeds/people/demo/friends&quot;
HTTP/1.1 200 OK
Server: Virtuoso/05.00.3021 (Linux) i686-pc-linux-gnu  VDB
Connection: Keep-Alive
Date: Wed, 14 Nov 2007 16:50:14 GMT
Accept-Ranges: bytes
Content-Type: application/atom+xml; charset=&quot;ISO-8859-1&quot;
Content-Length: 2104

&lt;feed xmlns=&quot;http://www.w3.org/2005/Atom&quot; xmlns:openSearch=&quot;http://a9.com/-/spec/opensearchrss/1.0/&quot; xmlns:georss=&quot;http://www.georss.org/georss&quot; xmlns:gd=&quot;http://schemas.google.com/g/2005&quot;&gt;
&lt;id&gt;http://localhost:8890/feeds/people/demo/friends&lt;/id&gt;
&lt;updated&gt;2007-11-14T18:50:14.000+02:00&lt;/updated&gt;
&lt;title&gt;demo&#39;s Friends&lt;/title&gt;
&lt;link rel=&quot;http://schemas.google.com/g/2005#feed&quot; type=&quot;application/atom+xml&quot; href=&quot;http://localhost:8890/feeds/people/demo/friends&quot;/&gt;
&lt;link rel=&quot;self&quot; type=&quot;application/atom+xml&quot; href=&quot;http://localhost:8890/feeds/people/demo/friends&quot;/&gt;
&lt;author&gt;&lt;name&gt;demo&lt;/name&gt;&lt;/author&gt;
&lt;entry xmlns=&quot;http://www.w3.org/2005/Atom&quot; xmlns:georss=&quot;http://www.georss.org/georss&quot; xmlns:gd=&quot;http://schemas.google.com/g/2005&quot;&gt;
&lt;id&gt;http://localhost:8890/feeds/people/dav&lt;/id&gt;
&lt;updated&gt;2007-11-01T10:33:10.000+02:00&lt;/updated&gt;
&lt;title&gt;WebDAV System Administrator&lt;/title&gt;
&lt;link rel=&quot;alternate&quot; type=&quot;text/html&quot; href=&quot;http://localhost:8890/dataspace/person/dav&quot;/&gt;
&lt;link rel=&quot;self&quot; type=&quot;application/atom+xml&quot; href=&quot;http://localhost:8890/feeds/people/dav&quot;/&gt;
&lt;georss:where&gt;
&lt;gml:Point xmlns:gml=&quot;http://www.opengis.net/gml&quot;&gt;
&lt;/gml:Point&gt;
&lt;/georss:where&gt;
&lt;gd:extendedProperty name=&quot;lang&quot; value=&quot;en-US&quot;/&gt;
&lt;gd:postalAddress label=&quot;Home&quot;&gt;&lt;![CDATA[
]]&gt;&lt;/gd:postalAddress&gt;
&lt;gd:postalAddress label=&quot;Work&quot;&gt;&lt;![CDATA[
]]&gt;&lt;/gd:postalAddress&gt;
&lt;/entry&gt;
&lt;entry xmlns=&quot;http://www.w3.org/2005/Atom&quot; xmlns:georss=&quot;http://www.georss.org/georss&quot; xmlns:gd=&quot;http://schemas.google.com/g/2005&quot;&gt;
&lt;id&gt;http://localhost:8890/feeds/people/alice&lt;/id&gt;
&lt;updated&gt;2007-11-02T18:01:04.000+02:00&lt;/updated&gt;
&lt;title&gt;alice&lt;/title&gt;
&lt;link rel=&quot;alternate&quot; type=&quot;text/html&quot; href=&quot;http://localhost:8890/dataspace/person/alice&quot;/&gt;
&lt;link rel=&quot;self&quot; type=&quot;application/atom+xml&quot; href=&quot;http://localhost:8890/feeds/people/alice&quot;/&gt;
&lt;georss:where&gt;
&lt;gml:Point xmlns:gml=&quot;http://www.opengis.net/gml&quot;&gt;
&lt;/gml:Point&gt;
&lt;/georss:where&gt;
&lt;gd:extendedProperty name=&quot;lang&quot; value=&quot;en-US&quot;/&gt;
&lt;gd:postalAddress label=&quot;Home&quot;&gt;&lt;![CDATA[
(Private Address), 
]]&gt;&lt;/gd:postalAddress&gt;
&lt;gd:postalAddress label=&quot;Work&quot;&gt;&lt;![CDATA[
]]&gt;&lt;/gd:postalAddress&gt;
&lt;/entry&gt;
&lt;/feed&gt;
</programlisting><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h2"> Activities API</bridgehead>
<para>The activities API is implemented as described in <ulink url="http://code.google.com/apis/opensocial/docs/gdata/activities/developers_guide_protocol.html">http://code.google.com/apis/opensocial/docs/gdata/activities/developers_guide_protocol.html</ulink></para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> Creating entries</bridgehead>
<para>To create a new entry client must be authenticated first, then it issue a POST request to the activities feed an Atom based xml representation like : </para>
<programlisting>&lt;atom:entry xmlns:atom=&quot;http://www.w3.org/2005/Atom&quot;&gt;
  &lt;atom:updated&gt;2007-10-29T19:00:51.574Z&lt;/atom:updated&gt;
  &lt;atom:category scheme=&quot;http://schemas.google.com/g/2005#kind&quot; term=&quot;http://schemas.google.com/activities/2007#activities&quot;/&gt;
  &lt;atom:title&gt;I&#39;m at work&lt;/atom:title&gt;
&lt;/atom:entry&gt;
</programlisting><para> The server will respond with entry containing atom:id element, below is a simple session for creating a new entry.
 The &quot;ODS Auth&quot; value is the sid value for the logged in user demo in ODS.</para>
<programlisting>curl -i -d &quot;`cat act.xml`&quot; -H &quot;Authorization: ODS Auth=032a81d688a275910bd5ef31aff6d5ab&quot; -H &quot;Content-Type: application/atom+xml&quot; &quot;http://localhost:8890/activities/feeds/activities/user/demo/source/0&quot; 
HTTP/1.1 201 Created
Server: Virtuoso/05.00.3021 (Linux) i686-pc-linux-gnu  VDB
Connection: Keep-Alive
Date: Thu, 15 Nov 2007 12:25:10 GMT
Accept-Ranges: bytes
Content-Type: application/atom+xml; charset=&quot;ISO-8859-1&quot;
Content-Length: 636

&lt;entry xmlns=&quot;http://www.w3.org/2005/Atom&quot;&gt;
&lt;id&gt;http://localhost:8890/activities/feeds/activities/user/demo/source/0/10&lt;/id&gt;
&lt;updated&gt;2007-11-15T14:25:10.000+02:00&lt;/updated&gt;
&lt;category scheme=&quot;http://schemas.google.com/g/2005#kind&quot; term=&quot;http://schemas.google.com/activities/2007#activity&quot;/&gt;
&lt;title&gt;I&#39;m at work&lt;/title&gt;
&lt;link rel=&quot;self&quot; type=&quot;application/atom+xml&quot; href=&quot;http://localhost:8890/activities/feeds/activities/user/demo/source/0/10&quot;/&gt;
&lt;link rel=&quot;edit&quot; type=&quot;application/atom+xml&quot; href=&quot;http://localhost:8890/activities/feeds/activities/user/demo/source/0/10&quot;/&gt;
&lt;received&gt;2007-11-15T14:25:10.000+02:00&lt;/received&gt;
&lt;/entry&gt;
</programlisting><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> Retrieving entries</bridgehead>
<para>The feed retrieval is just a GET against user activities feed, e.g., </para>
<programlisting>GET http://localhost:8890/activities/feeds/activities/user/demo
</programlisting><para>produces a Atom feed with users activities listed</para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> Updating entries</bridgehead>
<para>The update is similar to entry creation, but in this case the HTTP method must be PUT and the Atom entry must contain a valid atom:id, for example:</para>
<programlisting>&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;entry xmlns=&quot;http://www.w3.org/2005/Atom&quot;&gt;
  &lt;id&gt;http://localhost:8890/activities/feeds/activities/user/demo/source/12/8&lt;/id&gt;
  &lt;updated&gt;2007-10-27T19:41:51.574Z&lt;/updated&gt;
  &lt;category scheme=&quot;http://schemas.google.com/g/2005#kind&quot; term=&quot;http://schemas.google.com/activities/2007#activity&quot;/&gt;
  &lt;title&gt;Another Edited title&lt;/title&gt;
  &lt;link rel=&quot;self&quot; type=&quot;application/atom+xml&quot; href=&quot;http://www.google.com/activities/feeds/activities/user/userID/source/sourceID/a1&quot;/&gt;
  &lt;link rel=&quot;edit&quot; type=&quot;application/atom+xml&quot; href=&quot;http://www.google.com/activities/feeds/activities/user/userID/source/sourceID/a1&quot;/&gt;
  &lt;received&gt;2007-10-27T19:41:51.478Z&lt;/received&gt;
&lt;/entry&gt;
</programlisting><para> </para>
<bridgehead class="http://www.w3.org/1999/xhtml:h3"> Deleting entries</bridgehead>
<para>It&#39;s the same as update, just in this case the HTTP method is DELETE.</para>
<para>In cases where clients do not support PUT/DELETE , the X-HTTP-Method-Override HTTP header is supported; i.e., DELETE can be  represented by : </para>
<programlisting>POST /url HTTP/1.1
X-HTTP-Method-Override: DELETE
....
</programlisting><para><ulink url="CategoryODS">CategoryODS</ulink> <ulink url="CategoryVirtuoso">CategoryVirtuoso</ulink> <ulink url="CategoryOpenSocial">CategoryOpenSocial</ulink> <ulink url="CategoryWebSite">CategoryWebSite</ulink></para>
<para> </para>
</section></docbook>