[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/phpgwapi/doc/xmlrpc/ -> perl.txt (source)

   1  /* $Id: perl.txt 20295 2006-02-15 12:31:25Z  $ */
   2  
   3  Perl interfacing to egroupware updated for Frontier-RPC-0.07b4:
   4  
   5  The Frontier::RPC module available at CPAN is capable of logging into an
   6  egroupware server.  To authenticate your session after the initial login,
   7  however, requires a patch to Frontier.  This patch causes Frontier to create
   8  an Authentication header using username/password values.  We use the assigned
   9  sessionid and kp3 for this.
  10  
  11  NOTE: sessionid/kp3 values in this file are not valid.
  12  
  13  TODO:
  14  
  15  1. Apply the patch at the end of this file to Frontier-RPC-0.07b4.
  16  2. Install Frontier.
  17  3. Try the following method using rpc-client.pl in the examples subdirectory for
  18    the Frontier source:
  19  
  20      rpc-client.pl \
  21      http://www.egroupware.org/egroupware/xmlrpc.php \
  22      system.login \
  23      "{domain => '',username => 'demo', password => 'guest'}"
  24  
  25  4. Take the returned sessionid and kp3, e.g.:
  26  
  27  $result = HASH(0x826d4b0)
  28     'domain' => 'default'
  29     'kp3' => 'e0219714614769x25bc92286016c60c2'
  30     'sessionid' => '36f9ec1e4ad78bxd8bc902b1c38d3e14'
  31  
  32  5. Place these on the commandline for a new request, with sessionid for
  33  username and kp3 for password:
  34  
  35      rpc-client.pl \
  36      http://www.egroupware.org/egroupware/xmlrpc.php \
  37      --username 36f9ec1e4ad78bxd8bc902b1c38d3e14 \
  38      --password e0219714614769x25bc92286016c60c2 \
  39      service.contacts.read \
  40      "{ id => '4'}"
  41  
  42  6. This should return record #4 from the addressbook application.
  43  
  44  Other requests may require different types on the command line, e.g.:
  45  
  46      preferences.bosettings.read "addressbook,'','user'"
  47  
  48  Here is the patch:
  49  
  50  ----CUT HERE----
  51  diff -aur Frontier-RPC-0.07b4/examples/rpc-client.pl Frontier-RPC-0.07b4-milos/examples/rpc-client.pl
  52  --- Frontier-RPC-0.07b4/examples/rpc-client.pl    1999-09-02 15:16:49.000000000 -0500
  53  +++ Frontier-RPC-0.07b4-milos/examples/rpc-client.pl    2005-07-30 05:25:36.309201144 -0500
  54  @@ -1,4 +1,4 @@
  55  -#
  56  +#!/usr/bin/perl
  57   # Copyright (C) 1998 Ken MacLeod
  58   # See the file COPYING for distribution terms.
  59   #
  60  @@ -59,7 +59,9 @@
  61   
  62   GetOptions( 'debug' => \$debug,
  63               'encoding=s' => \$encoding,
  64  -            'proxy=s' => \$proxy );
  65  +            'proxy=s' => \$proxy,
  66  +            'username=s' => \$username,
  67  +            'password=s' => \$password);
  68   
  69   die "usage: rpc-client URL METHOD [\"ARGLIST\"]\n"
  70       if ($#ARGV != 1 && $#ARGV != 2);
  71  @@ -71,12 +73,18 @@
  72   $server = Frontier::Client->new( 'url' => $url,
  73                                    'debug' => $debug,
  74                                    'encoding' => $encoding,
  75  -                                 'proxy' => $proxy );
  76  +                                 'proxy' => $proxy,
  77  +                                 'username' => $username,
  78  +                                 'password' => $password);
  79  +
  80  +use Data::Dumper;
  81  +print Dumper($server);
  82   
  83   my @arglist;
  84   eval "\@arglist = ($arglist)";
  85   
  86   $result = $server->call ($method, @arglist);
  87  +print Dumper($result);
  88   
  89  -require 'dumpvar.pl';
  90  -dumpvar ('main', 'result');
  91  +#require 'dumpvar.pl';
  92  +#dumpvar ('main', 'result');
  93  diff -aur Frontier-RPC-0.07b4/lib/Frontier/Client.pm Frontier-RPC-0.07b4-milos/lib/Frontier/Client.pm
  94  --- Frontier-RPC-0.07b4/lib/Frontier/Client.pm    2002-08-02 19:48:06.000000000 -0500
  95  +++ Frontier-RPC-0.07b4-milos/lib/Frontier/Client.pm    2005-07-30 04:52:35.000000000 -0500
  96  @@ -42,6 +42,11 @@
  97       push @options, 'use_objects' => $self->{'use_objects'};
  98       }
  99   
 100  +    if(defined $self->{'username'} and defined $self->{'password'})
 101  +    {
 102  +        use MIME::Base64;
 103  +        $self->{'rq'}->header('Authorization' => 'Basic ' . encode_base64($self->{'username'} . ":" . $self->{'password'}));
 104  +    }
 105       $self->{'enc'} = Frontier::RPC2->new(@options);
 106   
 107       return $self;


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7