-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6b068f6
Showing
9 changed files
with
1,670 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
node-mailchimp | ||
============== | ||
|
||
A node.js wrapper for the MailChimp API. | ||
|
||
All functions of the MailChimp API (Version 1.3) and the MailChimp Export API | ||
(Version 1.0) as described on [http://www.mailchimp.com/api/](http://www.mailchimp.com/api/) | ||
are exposed to your node.js application. | ||
|
||
Installation | ||
------------ | ||
|
||
Installing using npm (node package manager): | ||
|
||
npm install mailchimp | ||
|
||
If you don't have npm installed or don't want to use it: | ||
|
||
cd ~/.node_libraries | ||
git clone git://github.com/gomfunkel/node-mailchimp.git mailchimp | ||
|
||
Usage | ||
----- | ||
|
||
More or less proper documentation can be found in the source code. Available | ||
API functions and their documentation can be found on | ||
[http://www.mailchimp.com/api/](http://www.mailchimp.com/api/). You can also | ||
find further information on how to obtain an API key and much more on the | ||
MailChimp API pages. | ||
|
||
MailChimp API: | ||
|
||
var MailChimpAPI = require('mailchimp').MailChimpAPI; | ||
|
||
var apiKey = 'Your MailChimp API Key'; | ||
|
||
try { | ||
var api = new MailChimpAPI(apiKey, { version : '1.3', secure : false }); | ||
} catch (error) { | ||
console.log('Error: ' + error); | ||
} | ||
|
||
api.campaigns({ start: 0, limit: 25 }, function (data) { | ||
if (data.error) | ||
console.log('Error: '+data.error+' ('+data.code+')'); | ||
else | ||
console.log(JSON.stringify(data)); // Do something with your data! | ||
}); | ||
|
||
api.campaignStats({ cid : '/* CAMPAIGN ID */' }, function (data) { | ||
if (data.error) | ||
console.log('Error: '+data.error+' ('+data.code+')'); | ||
else | ||
console.log(JSON.stringify(data)); // Do something with your data! | ||
}); | ||
|
||
MailChimp Export API: | ||
|
||
var MailChimpExportAPI = require('mailchimp').MailChimpExportAPI; | ||
|
||
var apiKey = 'Your MailChimp API Key'; | ||
|
||
try { | ||
var api = new MailChimpExportAPI(apiKey, { version : '1.0', secure: false }); | ||
} catch (error) { | ||
console.log('Error: ' + error); | ||
} | ||
|
||
exportApi.list({ id : '/* LIST ID */' }, function (data) { | ||
if (data.error) | ||
console.log('Error: '+data.error+' ('+data.code+')'); | ||
else | ||
console.log(data); // Do something with your data! | ||
}); | ||
|
||
ToDo / Ideas | ||
------------ | ||
|
||
* Implement API versions 1.1 and 1.2 | ||
* Implement WebHooks | ||
|
||
License | ||
------- | ||
|
||
node-mailchimp is licensed under the MIT License. (See LICENSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('./lib/mailchimp'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var MailChimpAPI_v1_3 = require('./MailChimpAPI_v1_3'); | ||
|
||
/** | ||
* Returns a MailChimp API wrapper object of the specified version. The only | ||
* API version currently supported is 1.3 but as soon as other versions are | ||
* implemented you can specify the one you want in the options parameter. | ||
* | ||
* Available options are: | ||
* - version The API version to use, currently only '1.3' is supported. | ||
* Defaults to '1.3'. | ||
* - secure Whether or not to use secure connections over HTTPS (true/false) | ||
* Defaults to false. | ||
* | ||
* @param apiKey The API key to access the MailChimp API with | ||
* @param options Configuration options as described above | ||
* @returns Instance of the MailChimp API in the specified version | ||
*/ | ||
function MailChimpAPI (apiKey, options) { | ||
|
||
if (!options) | ||
var options = {}; | ||
|
||
if (!apiKey) | ||
throw 'You have to provide an API key for this to work.'; | ||
|
||
if (!options.version || options.version == '1.3') | ||
return new MailChimpAPI_v1_3(apiKey, options); | ||
else | ||
throw 'Version ' + options.version + ' of the MailChimp API is currently not supported.'; | ||
|
||
} | ||
|
||
module.exports = MailChimpAPI; |
Oops, something went wrong.