Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-25-2007, 06:55 AM
Member
 
Posts: 13
Default Perl Module to simplify SOAP access to Zimbra

******* If you downloaded a copy of ZimbraSession.pm and it's not working ******* It's because I uploaded a broken copy. Please re-download the file
******* It should be working fine now. Sorry.

Hey all, I don't know if something already exist like this but I wrote a simple Perl module to simplify SOAP communications with the Zimbra server. Basically I just took some of the existing Perl scripts and converted them into methods, and put them in one module. Hopefully this can be of some use to someone. If some one knows of a better module please let me know. Or if you upgrade and make this one better please let me know. I will attach the module, and the crappy example file I made. Below is the example file so you can see how it's used. All the methods are really only for dealing with the Calendar because that's all I need it for. Hopefully someone will add to it and covert the scripts for email's to methods for this module.

This is how to use the module:

#!/usr/bin/perl -w

use lib '/usr/local/src/Zimbra/'; # Holds Soap.pm, Soap11, Soap12 Sudds.., XmlDoc, XmlElement, and ZimbraSession

use ZimbraSession;

################################################## ############
#
# All these methods return the SOAP response from the server.
#
################################################## ############

##############################
# Create New Appointment
##############################

# As an option you can set acctns and mailns. By default they are set to urn:zimbraAccount and urn:zimbraMail respectively.

my $zs = ZimbraSession->new(
{name => 'Display Name', login => 'username'},
'password',
'http://yourhost.net/service/soap/',
# {acctns => '', mailns => ''}
);

my $attendees = [
{name => 'Matt Foley', email => 'mfoley@email.com'},
{name => 'Bill Brasky', email => 'bbrasky@email.com'}
]; # List of attendees to invite to an appointment


# For now this will only set an appointment in your default Calendar.
# These are not recurring appointmetns like the createAppt.pl script

my $appointment = $zs->createAppt(
'Subject', 'Location',
'', # Show as
'', # Calendar
'Start Time',
'End Time',
'', # Recuring
$attendees,
'Plain Text Message',
"HTML Message",
''
);

#####################
# Cancel Appointment
#####################

my $cancel_appointment = $zs->cancelAppt($invId, $subject, $message, $attendees);

###########################
# Retrieve an Appointment
###########################

my $appointment = $zs->getAppt($apptId);

##################################
# Retrieve Appointment Summaries
##################################

my $summaries = $zs->getApptSummaries($start_time, $end_time);

##################################
# Modify an Appointment
##################################

my $modified_appt = $zs->modifyAppt(
$invId, $mode, $end_time,
$subject, $message, $location,
$current_attendees, $new_attendees
);

##################################
# Create Folder
##################################
# Right now I believe this only creates Calendars, because that's all I needed, but it can easily be modifed to
# create folders. You just need to figure out the correct 'view' and edit it the method.

my $folder = $zs->createFolder($folder_name);

##################################
# Delete Folder
##################################

# I dont think you can use the folder name here.
# The folder id is returned in the respone from createFolder();

my $deleted_folder = $zs->deleteFolder($folder_id);
Attached Files
File Type: txt ZimbraSessionExample.txt (3.3 KB, 422 views)
File Type: txt ZimbraSession.pm.txt (11.3 KB, 784 views)

Last edited by crankin; 10-25-2007 at 07:47 AM.. Reason: I uploaded the wrong version of ZimbraSession.pm
Reply With Quote
  #2 (permalink)  
Old 10-25-2007, 09:49 AM
Zimlet Guru & Moderator
 
Posts: 467
Default

Cool stuff. I am stickying this for right now, but could you also add this information to the Zimbra Wiki?
Reply With Quote
  #3 (permalink)  
Old 10-25-2007, 10:21 AM
Former Zimbran
 
Posts: 5,606
Default

Nice.
Crankin- can you PM me your shipping info and I'll send you out a shirt.

jh
Reply With Quote
  #4 (permalink)  
Old 10-25-2007, 01:51 PM
Member
 
Posts: 13
Default

Quote:
Originally Posted by JoshuaPrismon View Post
Cool stuff. I am stickying this for right now, but could you also add this information to the Zimbra Wiki?
Yes, I will upload it to the Wiki.
Reply With Quote
  #5 (permalink)  
Old 10-25-2007, 03:33 PM
Member
 
Posts: 13
Default

Wiki is up.

EDIT (mmorse):
Login and manipulate Zimbra account with Perl - Zimbra :: Wiki

Last edited by mmorse; 07-03-2008 at 12:08 PM..
Reply With Quote
  #6 (permalink)  
Old 06-11-2009, 09:30 AM
New Member
 
Posts: 3
Default ZimbraSession Extensions

Great module. Thanks.

At Eastern Michigan University we needed a way to migrate course calendars.
So, I made a few changes specific to our needs (namely, support for shared calendars and recurring appointments).

I figured I'd post the code as a continuation to this thread. I can't guarantee the code will work for everyone, but it works very well for us.
Attached Files
File Type: txt ZimbraSession.pm.txt (11.6 KB, 64 views)
File Type: txt testcreatecal.pl.txt (5.5 KB, 59 views)
Reply With Quote
  #7 (permalink)  
Old 04-20-2010, 03:43 PM
Junior Member
 
Posts: 6
Default

Don't work!!
I try both class but doesn't work!!
The AuthResponse dont has the sessionid!!
Reply With Quote
  #8 (permalink)  
Old 04-21-2010, 05:39 AM
New Member
 
Posts: 3
Default Session Id is not used

If you look carefully, you'll see that session id is not actually used in the code and was removed in one of the point releases of Zimbra (I can't remember which). Just comment out or remove lines in the code that get the session id out of the AuthResponse.
Reply With Quote
  #9 (permalink)  
Old 04-21-2010, 05:55 AM
New Member
 
Posts: 3
Default Updated Code

Anyway, try this. It has my most recent changes.
Attached Files
File Type: zip Zimbra Calendar.zip (60.0 KB, 63 views)
Reply With Quote
  #10 (permalink)  
Old 04-21-2010, 08:24 AM
Junior Member
 
Posts: 6
Default

Thankyou so much!!
It realy works!!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.