Return to Snippet

Revision: 4653
at January 14, 2008 17:38 by eszpee


Initial Code
#!/usr/bin/perl
use strict;
use LWP::UserAgent;
my $silent = 0; # set to 1 for no output on stdout
my $logindata = {
    'j_username' => 'fill in your username (email)',
    'j_password' => 'fill in your password',
    'j_remember' => 'on',
                };
my $loginurl = 'http://crm.zoho.com/crm/zohologin';
my $backupurl = 'http://crm.zoho.com/crm/ExportEntity.do';
my @backuptables = qw{Users Leads Accounts Contacts Potentials Campaigns Tasks Events Notes Competitors Products PriceBooks Cases Solutions Forecasts Vendors Quotes SalesOrders PurchaseOrders Invoices};

my $ua = LWP::UserAgent->new;
$ua->cookie_jar({ file => "cookies.txt" });

print qq{get cookie from frontpage...} unless $silent;
my $devnull = $ua->get('http://crm.zoho.com/crm/login.sas'); #get cookie
print qq{done.\n} unless $silent;

print qq{login as $$logindata{'j_username'}...} unless $silent;
my $loginresponse = $ua->post($loginurl, $logindata);
print qq{done.\n} unless $silent;

foreach my $whichtable (@backuptables) {
	print qq{exporting $whichtable.csv...} unless $silent;
	my $backupdata = {
		'module' => $whichtable,
	};
	my $backuptable = $ua->post($backupurl, $backupdata);
	open (KI, ">$whichtable.csv");
	print KI $backuptable->content;
	close (KI);
	print qq{done.\n} unless $silent;
}

Initial URL

                                

Initial Description
fill your username and password

Initial Title
Backup all your tables from ZOHO CRM in CSV format

Initial Tags
script, backup, csv

Initial Language
Perl