[development] Continued Services woes

jeff at ayendesigns.com jeff at ayendesigns.com
Mon Mar 7 21:40:34 UTC 2011


Victor, two questions regarding this (for now). Where does another 
server sending the request get a session id to send? 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. 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/d3707f6a/attachment-0001.html 


More information about the development mailing list