| Email-ConstantContact documentation | view source | Contained in the Email-ConstantContact distribution. |
Email::ConstantContact - Perl interface to the ConstantContact API
Version 0.05
This module allows you to interact with the ConstantContact mass email marketing service from perl, such as creating and mainting contacts and contact lists.
Before using this module, you must register your application with the ConstantContact company, agree to their terms & conditions, and apply for an API access key. You will use this key, in combination with a ConstantContact username and password to interact with the service.
use Email::ConstantContact;
my $apikey = 'ABCDEFG1234567';
my $username = 'mycompany';
my $password = 'topsecret';
my $cc = new Email::ConstantContact($apikey, $username, $password);
# How to enumerate existing Contact Lists:
my @all_lists = $cc->lists();
foreach my $list (@all_lists) {
print "Found list: ", $list->{Name}, "\n";
}
# How to create a new Contact List:
my $new_list = $cc->newList('JAPH Newsletter', {
SortOrder => '70',
DisplayOnSignup => 'false',
OptInDefault => 'false',
});
# How to add a new contact:
my $new_contact = $cc->newContact('jdoe@example.com', {
FirstName => 'John',
LastName => 'Doe',
CompanyName => 'JD Industries',
ContactLists => [ $new_list ],
});
# How to modify existing contact:
my $old_contact = $cc->getContact('yogi@example.com');
print "Yogi no longer works for ", $old_contact->{CompanyName}, "\n";
$old_contact->{CompanyName} = 'Acme Corp';
# Enumerate List Membership
print "Member of Lists: \n";
foreach my $listid (@{ $old_contact->{ContactLists} }) {
my $listobj = $cc->getList($listid);
print $listobj->{Name}, "\n";
}
# Manage List Membership
$old_contact->removeFromList($some_list_id);
$old_contact->clearAllLists();
$old_contact->addToList($new_list);
$old_contact->save();
# Opt-Out of all future emails
$old_contact->optOut();
$old_contact->save();
# Display recent activities
my @recent_activities = $cc->activities();
foreach my $activity (@recent_activities) {
print "Found recent activity, Type= ", $activity->{Type},
"Status= ", $activity->{Status}, "\n";
}
# Obtain bounced email addresses.
foreach my $camp ($cc->campaigns('SENT')) {
foreach my $event ($camp->events('bounces')) {
if ($event->{Code} eq 'B') {
print "Bounced: ", $event->{Contact}->{EmailAddress}, "\n";
}
}
}
Adam Rich, <arich at cpan.org>
Please report any bugs or feature requests to bug-email-constantcontact at rt.cpan.org, or through
the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Email-ConstantContact. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Email::ConstantContact
You can also look for information at:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Email-ConstantContact
Copyright 2009-2011 Adam Rich, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Email-ConstantContact documentation | view source | Contained in the Email-ConstantContact distribution. |