[development] Continued Services woes

Victor Kane victorkane at gmail.com
Mon Mar 7 21:49:01 UTC 2011

On Mon, Mar 7, 2011 at 6:40 PM, <jeff at ayendesigns.com> wrote:

>  Victor, two questions regarding this (for now). Where does another server
> sending the request get a session id to send?

Second line:

$anon_session = xmlrpc($server, 'system.connect');

This is then reused in the login request:

$authenticated_session = xmlrpc($server, 'user.login',
$anon_session['sessid'], $user, $password);

> And in this example, and really every one I've seen, a standard method is
> being used (node.get in this one), but I'm wondering if part of the issue is
> that I'm defining a method in my module as opposed to using one packaged
> with the services module.

That's fine. I did the same thing recently, for example uploading
performance times to a performance content type. I copied the closest
existing service module into my own module and edited it. That way, I had my
own custom service written as part of services.

For a bare-bones xmlprc example using Drupal functions without the services
module, check out my 2007 article leveraging hook_xmlrpc:


This gets it done.

Either way, your own code can implement the logic you describe.


>  In my case, I'm receiving data, and if its id matches a cck value in a
> content type I take the data and update a field in the node with it, if not,
> I put the data into a holding queue until there -is- a node with the id
> being matched by the cck field.
> On 03/07/2011 04:14 PM, Victor Kane wrote:
> Maybe this will help. I recently launched
> http://projectflowandtracker.com/ (on Pantheon, yay!) in alpha (beta will
> come with jquery enhanced usability improvements) and was working on an
> everything in code basis; so... I had to import from the legacy site all the
> projects, user stories, etc. for the 150-200 folks who had been using the
> previous version.
>  I opted to use services on the legacy site, and did not use the
> authentication key, but opted for user login instead, bringing the stuff
> over to the new site using the Drupal API
> http://api.drupal.org/api/drupal/includes--common.inc/function/xmlrpc/6 which
> does not need to be downloaded or required.
>  /*
>  * client code for use with Services 6.x-2.4
>  *    with following modules enabled on server, and following server
> config:
>  *      Key Authentication, XMLRPC Server, Node Service, System Service,
> User Service, Views Service
>  *    with no special permissions for anonymous on server
>  *    Key Authentication is chosen at Site building > Services > Settings
>  *      but Use ssid selected, Use keys de-selected
>  */
>  $server = 'http://legacy.projectflowandtracker.com/services/xmlrpc';
>  $anon_session = xmlrpc($server, 'system.connect');
>  // login as...
> // Use anon session id to login with authentication
> $user = 'the_user';
> $password = 'the_password';
> $authenticated_session = xmlrpc($server, 'user.login',
> $anon_session['sessid'], $user, $password);
>       if (xmlrpc_error()) {
>       $error_num = xmlrpc_errno();
>       $error = xmlrpc_error();
>       print_r ($error);
>       }
>  /*********** code just to bring a single node ****************/
> $xmlrpc_result = xmlrpc($server, 'node.get',
> $authenticated_session['sessid'], 2);
>       if (xmlrpc_error()) {
>       $error_num = xmlrpc_errno();
>       $error = xmlrpc_error();
>       print_r ($error);
>       }
> print '<pre>' . print_r($xmlrpc_result, TRUE) . '</pre>';
>  This worked for me.
>  Victor Kane
> http://awebfactory.com.ar
> http://projectflowandtracker.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20110307/3d62f40b/attachment.html 

More information about the development mailing list