Please login or register to participate.
Wiki Page

Getting new items via PHP and XMLRPC

  1. Install phpxmlrpc ( )
  2. Use the following code on your page:



$admin = "siteadmin";
$password = "secret";
$numberofitems = "8";

$xmlrpc_internalencoding = 'UTF-8';
$client = new 
$client->return_type = 'phpvals';

$message = new xmlrpcmsg("getRecentUpdates",array(new xmlrpcval($numberofitems, "int")));
$resp = $client->send($message);

$x = 0;
foreach($resp->val['itemlist'] as $result){
        // Icons
        $iconmessage = new xmlrpcmsg("getTypeInfo", array(new xmlrpcval($result['portal_type'], "string")));
        $iconresp = $client->send($iconmessage);
        $iconurl = $iconresp->val['typeiconurl'];
        echo "<img src='" . $iconurl . "'>";

        $zeit = $result['modified'];
        $titel = $result['title'];
        $ersteller = $result['creator'];
        echo " " . $titel . "<br />";
        echo "<h5><b>" . $ersteller . " um  " . $zeit . "h</b></h5><br />";



How to use PHP and XMLRPC to list a configurable number of new items in your portal.
Comments (10)
gsiak May 25, 2010 10:58 AM
This example didn't work for me on 3.1.3. Are there any changes in the meantime?
mdebus May 26, 2010 08:21 PM
This code works for me in 3.1.3. What doesn't work? Any errors?
gsiak May 27, 2010 12:11 PM
xmlrpcmsg doesn't deliver any result. Is there a log on server side? The desktop client is working fine, so I can exclude access probs.
dhiraj May 27, 2010 12:36 PM
@guido: Hmm... try turning error logging on, in your php file, if it's not already on. When you say "doesn't deliver any result" you're checking the value of $resp, yes?

There's also a debug mode in php xmlrpc, from what I remember - we did that stuff quite a while back when we were doing auth integration for It will show you what the call actually returned from

We're using an xmlrpc call at drupal to call this community you're commenting on, to authenticate you so it works, let me assure you. :)

Now, to figure out why you're not getting results -> Maybe the user you're querying with doesn't actually *have* any items to see? It all depends, on your scenario and your script. If you want to try a little python, you can start off an interactive python prompt to query the user in a few lines and validate your logic in a parallel way, like so:

Login, get and set status message, looks like this:

dhiraj@dhiraj:~$ python
Python 2.6.2 (release26-maint, Apr 19 2009, 01:58:18)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from xmlrpclib import ServerProxy
>>> ser = ServerProxy("http://siteadmin:secret@SITEHOSTNAME/cynin/stacker")
>>> ser.sayhello()
>>> ser.getStatusMessage()
>>> ser.setStatusMessage('Hello World')
'Hello World'
>>> ser.getStatusMessage()
'Hello World'
dhiraj May 27, 2010 12:39 PM
So like that you can set the status message of the current user, in above example, the current Status message of the siteadmin user would be set to Hello World, and it would show up on the UI when somebody clicked on their avatar.

Other API functions can be tested similarly.
gsiak May 27, 2010 10:53 PM
I have spend some time investigating in the issue. First of all, both versions of the provide by link on top of the page didn't fit to php 5.2. I have made a change in beta version manually and now is working.
Solving the first challange, next came up:
Debug info::Sorry, the requested resource does not exist. Check the URL and try again. Resource: http://localhost:8080/cynin/VirtualHostRoot

Seems, that rewrite rules provided in ISO installation (and working fine for causes an error in xmlprc call. I've tried IP address as well as domain name as server address. Any hint for me?
dhiraj May 27, 2010 11:03 PM
I will ask someone to checkout what version we're using for our auth module and update.

I'm definitely sure about the virtualhostmonster rewriting the URLs safely for XMLRPC as well as for main site - it's rewritten in exactly the same way and the default works. There is normally no separate rewrite rule for the XMLRPC API.

Example: If you call your site at, then your xmlrpc endpoint URL will be <- replace end-point depending upon use case. In most cases above endpoint is to be used.
There are 2 more endpoints, 1 for anonymous calls (forgot password) and 1 for admin-only calls (create user).

If rewriting is not working or something else is wrong, you can safely communicate with instance directly, for xml-rpc.
If your site runs at port 8080, on IP:, then you can call same stacker API above by using URL
Note the positing of the words cynin and stacker in above URL. cynin is the site object name and stacker is the API endpoint.

It is mandatory to specify API endpoint, this is the basis of the security interface.
gsiak May 28, 2010 10:43 PM
Python example as described and access from outside works fine for tested methods.
Now I'm investigating PHP implementation for causing the error because parameter, server address, path etc.are same but error is returned by Zope using for PHP.
gsiak May 31, 2010 09:29 AM
Seems that will change all method names to lower before calling. I've found some comments on it and some source like strtolower(). If tried misspelling in Python wich causes similiar error message.
dhiraj May 31, 2010 09:55 AM
We are using this doing xmlrpc from php. This does not seem to be causing any problems, although I can't off-hand say that we have in fact checked it for case sensitivity problems.

What are you using?

=====Pasting from
// by Edd Dumbill (C) 1999-2002
// <>
// $Id:,v 1.174 2009/03/16 19:36:38 ggiunta Exp $

// Copyright (c) 1999,2000,2002 Edd Dumbill.
Back relations