Please login or register to participate.
Wiki Page

XMLRPC API

.

    def getSiteTitle(self):
        """Return the site title"""
    def getRecentUpdates(self,maxitemcount=5,pagenumber=1):
        """Return the recent updates"""
    def refreshUpdateItem(self,uid):
        """Resends a single item of the same structure as the one in getRecentUpdates with the most updated info"""
    def getTypeInfo(self,typename):
        """Returns the type title and icon url for given typename"""
    def getUserInfo(self,userid):
        """Return the user name details, and avatar url for given userid"""
    def getWikiBody(self,uid):
        """Return the wiki body text, pre-cooked and processed"""
    def getEventInfo(self,uid):
        """Return the information available for a Calendar Event"""
    def getFileInfo(self,uid):
        """Return the info available for a file"""
    def getLinkInfo(self,uid):
        """Return the info available for a link"""
    def getBlogEntry(self,uid):
        """Return the info available for a Blog Entry"""
    def getComments(self,uid):
        """Return all the comments for the given object's UID"""
    def addNewComment(self,uid,subject,text,commenter):
        """Adds a comment on the provided UID with given subject, text and commenter user"""
    def replyToComment(self,uid,subject,text,commenter):
        """Replies to the given comment's UID with given subject, text and commenter user"""   
    def getUpdateCount(self):
        """Returns number of recent items available for recent user"""
    def search(self,searchableText,maxitemcount=5,pagenumber=1):
        """Returns result for search text entered for recent user"""
    def searchIds(self,searchableText='',maxitemcount=5,pagenumber=1):
        """Returns search results with only id, lastchangedate and relevance for search text entered."""
    def getStatusMessages(self,username='',count=1,pagenumber=1):
        """Returns current status message for passed username. For empty username method returns status message for current user"""
    def getStatusMessage(self,username=''):
        """Returns current status message of passed user as string"""
    def setStatusMessage(self,message):
        """Set status log message for current user"""
    def getLastChangeDate(self):
        """Returns the max lastchangedate for the logged in user."""
    def getRecentItemIds(self,maxitemcount=5,pagenumber=1):
        """Return the recent UIDs, up to a maximum of maxitemcount items will be returned in a list"""
    def getSearchItemsByIds(self,arrUIDs):
        """Return the search items as per the UIDs requested."""
    def getItemsByIds(self,maxitemcount=5,pagenumber=1):
        """Return the Update items as per the UIDs requested."""
    def getUsersByIds(self,arrUserIds):
        """Return the user info objects for the users specified"""
    def getTypesByNames(self,arrTypeNames):
        """Return the type info objects for the type names specified"""

Python Example

Create a script called 'sitetitle.py'

import xmlrpclib
username = "yourname"
password = "yourpassword"
siteurl = "http://www.cynapse.com/community" # change this to match your cyn.in portal
proxy = xmlrpclib.ServerProxy("http://%s:%s@%s/stacker" % (username,password,siteurl))
print proxy.getSiteTitle()

The expected output will look like this:

python sitetitle.py

similar code could easily be added to any python framework to support interaction with your cyn.in portal

PHP Example

To do this with PHP, look here: Getting new items via PHP and XMLRPC
Description
List of methods and their purpose that are currently exposed by cyn.in. This is maintained with respect to 2.1 release.
Comments (29)
pigeonflight Jan 15, 2010 01:49 PM
now I just need example snippets of using this api, for example with python's built in xmlrpc
dhiraj Jan 15, 2010 02:29 PM
The usage borders on ridiculously simple from python! :)

from xmlrpclib import ServerProxy
ser = ServerProxy("http://username:password@cyninsite/stacker")
ser.sayhello()
dhiraj Jan 15, 2010 02:31 PM
This documentation needs updating, the XMLRPC API has evolved a bit since last posting here. The key file to look at is interfaces.py

Actual implementation is in stacker.py
mdebus Jan 24, 2010 07:22 PM
Do you have any example code for PHP as well? I tried with phpxmlrpc but it seems not to work. TIA!
mdebus Jan 27, 2010 05:01 PM
Nevermind - got it. Wiki article here: [[getting-new-items-via-php-and-xmlrpc]]
pigeonflight Jan 30, 2010 06:31 AM
that stacker name isn't very "obvious", now that I know it I'm cool though
seletz Feb 03, 2010 10:48 PM
**please** have a look at the wsapi4plone effort and do integrate with it. http://pypi.python.org/pypi/wsapi4plone.core
dhiraj Feb 04, 2010 09:52 AM
Hi seletz,

We're already looking at wsapi4plone, and it's companion products. We'll hopefully integrate it in a future version.

I'd actually tried it out with Cyn.in a while back, it wasn't working with the default setup and Cyn.in content types, I think some effort is required, just didn't have the available effort and resources to go into it at the time. It's a good product, and we'll try to include it soon.
domderrien Apr 01, 2010 03:19 AM
I hope that's the right place for my questions :)
- I can see that most of the methods listed above are getters.
- Is there any calls to add/update/delete items in {blog, wiki, bookmark, calendar event, etc.}?
- Do you have implemented the concept of Web hooks? That remote tools can use to trigger update Cynin side?

I'm interested in integrating Cynin with other open-source tools. 1) Someone creates an order entry, all attached documents are pushed to Cynin, and the order is updated with the corresponding links to the documents. 2) Someone change the state of a remote entry, and the state of a Cynin element has to be updated (this update can trigger other operations as defined by the workflow). 3) Someone cancels a remote entry and the corresponding Cynin item has to be deleted (item history included).

Cynin can then become the central hub for the enterprise collaboration!
dhiraj Apr 01, 2010 11:51 PM
It sounds interesting, what you're trying to achieve, domderrien.

The XML-RPC API was purpose built for the Cyn.in desktop to begin with, and we add methods as we go forward. There's setter methods for user status messages, and discussions, but that's it currently.

It's possible to add new methods to the API, but this requires at least a little knowledge of Plone and Cyn.in code to achieve. You might want to consider approaching Cynapse for a commercial engagement to provide you updated API for fitting your direct needs more easily. Or you could dive a bit deeper and explore how the API is currently implemented (in stacker.py in the ubify.xmlrpc product) and see if you can go about adding your own methods into it.

Adding of files is already possible programmatically, btw. You can use a HTTP PUT call to upload the file at your target URL (using the authenticated URL format - http://username:password@cyninsiteurl/spacepath/target_filename).
domderrien Apr 02, 2010 06:44 PM
Thanks Dhiraj,

Cyn.in is a very nice collaboration platform. My partner and I have started to propose it to enterprises having already an experience in the “cloud” and with the “SaaS” business model. Even if the barrier to adoption is not that high, we have to accommodate Cyn.in to their existing environment (shared folders, ERP & CRM systems, etc.). For example, the WebDAV extension helps the adoption but it lacks many features like the tagging, the notification management, etc.

Ideally, I would like to extend the Desktop client with a "New" button and to provide Portlets:
- The Desktop client mainly for its drag'n'drop support and its notification mechanism,
- Portlets for a seamless integration in existing enterprise portals.
First Cyn.in adopters will then use it transparently. Eventually, they'll switch to the Web interface because it offers a better collaborative experience (rating, tags, collaborator names, etc.). And the rest of the enterprise will follow them.

Thanks for proposing the commercial engagement. It's too early to know if it's worth engaging you because our prospects are still uncertain about their needs. We'll probably adopt the Agile approach: provide features in small steps, to get customer feedback & re-prioritization quickly. From our perspective, it will be easier to develop the features ourselves and to contribute them back to the community when they are stable.
domderrien Apr 02, 2010 06:58 PM
Dhiraj, another question ;)

Because you responded to my questions related to VirtualBox, you'll probably have guessed that we approach our prospects with proof-of-concept (POC) running in virtual machine instances (VMs). In the long run, we'll engage them to go with the On-Demand solution or with the On-Premise appliance. Good for both of us, isn't it? ;)

If I do develop new APIs to add more remote capabilities to Cyn.in, will I be able to apply the corresponding patches to the hosted environment? For sure, I'll contribute them back to the community, so I'm not concerned about who can apply them (yourself or myself). I'm more concerned about the delay:
- If there's a way to upload a patch, I can then fix an issue or extend a features very quickly.
- If you've to review/package/deploy the patch, then it can be many days with impacts on production.

Thanks for your help.
gsiak May 19, 2010 01:32 PM
Hi, will it be possible to setup an API for new discussions together with a predefined space as parameter. I have to design an external webpage where useres should be enabled to start new discussion topics.
dhiraj May 21, 2010 08:11 AM
This is already possible. Have a look at the .... addDiscussion() method I think it was called. Don't have the file with me at the moment, but you should look it up, adding discussions in a Space is already there in the API, methinks.
gsiak Jun 03, 2010 12:23 PM
Where can I find a list of all existing XMLRPC methods with parameter description (...but you should look it up..) ?
dhiraj Jun 03, 2010 12:44 PM
Here: http://odn.cynapse.com/[…]/interfaces.py

Alternatively, use this URL for a syntax highlighted view (requires cynapse.com login):
http://odn.cynapse.com/[…]/interfaces.py
gsiak Jun 15, 2010 09:24 PM
Is there also a description of return data structure available? We are using Java as client, which requires data type description of returned values.
dhiraj Jun 16, 2010 12:43 PM
Hmm... good point, the interface contract does not define the return structure. Consider going through the python code of the particular API methods you want to hook up. Typically the implementation will be found in stacker.py and from this you can figure out what the return might be.
Note: Sometimes the return can vary in error conditions, so I'm not really sure that endpoint marshalling/stub code might be up to the task, in Java. Remember to study the particular method codes to analyze if an error will return something or throw an XML-RPC fault. In case of fault the result should be handle-able, in Java.

Consider putting down a simplified example for your Java end-point for discussion and usage by the community as well, just like the PHP one. :)
gsiak Jun 16, 2010 11:30 PM
Yes, we will post Java code as soon as testing is finished. THX for your remarks.
stefan_v Jun 21, 2010 12:12 PM
I try to implement a JavaClient for Cynapse. I already got an array of Strings (getTypeInfo) without any problems. Now I tried to call the method "getRecentUpdates" and receive the message "Unexpected Zope exception: exceptions.TypeError - can't multiply sequence by non-int". Any ideas, how to solve the problem?
dhiraj Jun 21, 2010 12:44 PM
Hmm.... Are you sending any parameters to getRecentUpdates() call? This looks like an argument parsing / sending exception? Does it say something more specific on the Cyn.in Server side in an exception trace in the instance log?

How to see this log? Either run your test Cyn.in instance in "fg" mode (with ./bin/instance fg command) or do a tail -f on both the log files in <buildout home>/var/logs folder if you're testing with your testing with your live production.
stefan_v Jun 21, 2010 01:42 PM
I changed the parameters and now it works fine. thank you for your suggestion.
gsiak Jun 22, 2010 08:09 PM
Using getRecentUpdates method, the message text contains special characters which are HTML coded. The title text contains different coded character. Which format is it? utf-8?
dhiraj Jun 22, 2010 09:32 PM
Yes, output should be utf-8 encoded. What's going wrong?
gsiak Jun 23, 2010 08:43 AM
Java will have some issues handling utf-8. We will try to solve. Just wondering about HTML codes in message text which are different to title text. The HTML codes are shown in desktop client header text in detail view, which I have already reported in bug tracker.
stefan_v Jul 05, 2010 02:26 PM
Are there more methods? For example to get the Searchfolders or the Areas? Or is this the full list?
dhiraj Jul 06, 2010 09:28 AM
The full, updated list of functions is always available from the interfaces.py file in the ubify.xmlrpc product. Similarly stacker.py has definition for most of the methods in the interfaces.py contract.

ODN view (cynapse.com login required): http://odn.cynapse.com/[…]/interfaces.py

Adding new methods to the API is not difficult; is there a particular function that you need? If you're looking to get a list of Spaces that are available, look at using the getSpaces() call; this will return a nested struct of Spaces that are visible to the user you're using to call the method.
stefan_v Jul 06, 2010 04:03 PM
thanks, the getSpaces() was exactly what I was looking for!
 
Loading