nufyoot / createsend-node Goto Github PK
View Code? Open in Web Editor NEWNode.js Campaign Monitor API wrapper
License: MIT License
Node.js Campaign Monitor API wrapper
License: MIT License
The JSON.parse failed and crashed our live server today. Potentially / probably bad return data from Campaign Monitor but we can't afford this crashing our server so wrap it in a try/catch like above? And/or check to ensure it's a JSON string before trying to parse?
https://github.com/nufyoot/createsend-node/blob/master/lib/interface/utils.js#L57
Error stack trace:
SyntaxError: Unexpected token <
at Object.parse (native)
at Request._callback (/var/www/dropprice1/node_modules/createsend-node/lib/interface/utils.js:55:35)
at Request.self.callback (/var/www/dropprice1/node_modules/request/request.js:368:22)
at Request.EventEmitter.emit (events.js:98:17)
at Request.<anonymous> (/var/www/dropprice1/node_modules/request/request.js:1219:14)
at Request.EventEmitter.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/var/www/dropprice1/node_modules/request/request.js:1167:12)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at /var/www/dropprice1/node_modules/newrelic/node_modules/continuation-local-storage/node_modules/async-listener/glue.js:188:31
rather than harassing you for full documentation, I was wondering if you could share a little insight on how to use getActiveSubscribers? I'm very new to both node and campaign monitor and struggling a bit.
what I've got:
//more module dependancies above
var createsend = require('createsend-node'),
auth = { apiKey: 'XXXXXXXX' },
api = new createsend(auth);
//unsub is my mongo schema
unsub.statics.CMCall = function(callback){
//where do i provide the listid???
api.list.getActiveSubscribers(
function (err, subscribers){
for( var i = 0; i < subscribers.length; subscribers++){
console.log(subscribers[i]);
}
}
);
When a user subscribes to a list is it possible to add them into other lists at the same time?
Hi there,
I have tried to post new subscribes to a list using the node.js wrapper and kept getting unknown parameter ConsentToTrack
. This would happen every time I pass a value to the key ConsentToTrack
. If I leave the value as an empty string, the POST call succeeds but that's of no use for me as I need to track users. Anyhow, I've contacted Campaign Monitor and this was their reply:
In the last few months we updated our API to v 3.2, and as such, all of our own wrappers were updated as well: https://www.campaignmonitor.com/api/wrappers/ However, as you can see there, we don't actually manage the Node wrapper solution, so it's most likely not been updated to v3.2, which would mean it doesn't support the newer Consent to Track field. You'd either need to use one of our own supported wrappers, or manage that consent to track field in app or via list imports.
This is the code I was using:
`const createsend = require('createsend-node');
const auth = { apiKey: 'api-key'};
const api = new createsend(auth);
const userName = user_first_name;
const userEmail = user_email;
const listId = 'list-id'
const details = {
EmailAddress: userEmail,
Name: userName,
"ConsentToTrack": "Unchanged"
};
api.subscribers.addSubscriber(listId, details, (err, res) => {
if (err) console.log(err);
console.log(res);
})`
Not sure it's an issue but worth flagging it here. Your feedback is much appreciated.
Alin
P.s. I got it working with the Python wrapper but I'd very much prefer node.js :D
Currently, all the functions use callbacks. It would be nice to update to use promises & async/await functionality.
I'm trying to attach two PDFs to a smart transaction email. Sending with a single attachments works fine but with two, I get the error ESOCKETTIMEDOUT
Both PDFs that I am including in the attachments array send fine on their own so it's not a file format issue.
Using latest version of this package 0.8.2
ConsentToTrack is a settable attribute when adding to a subscription. https://www.campaignmonitor.com/api/subscribers/#adding-a-subscriber
However adding "ConsentToTrack": "Yes"
to user details on either subscribers.addSubscriber()
or subscribers.updateSubscriber()
returns "SyntaxError: Unexpected string".
I would like to use this on a project but when I attempt to get a list, I am getting a (node:9628) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. warning. Is this project still active or is it dead?
What seems to me from following example, is that library will return just body of response for err
or data
, what about headers? What if i need status code of response?
...transactional.sendSmartEmail({
To: [...],
Data: {...},
smartEmailID: ...,
clientID: ...
}, function (err, data) {
if (err) {
console.log('ERROR', err)
} else {
console.log('RESPONSE', response)
}
})
For example if recipient is omitted, err
would be:
{
Code: 952,
Message: 'Recipient is required. At least one To, CC, or a BCC address is required'
}
I try adding a subscriber to a list:
const api = new createsend(auth)
const details = {
EmailAddress: '[email protected]',
Name: 'Joris Joris'
}
api.subscribers.addSubscriber('some-list-id', details, (err) => {
if (err) {
Result:
[Error: Unable to parse JSON. Error: Error: Can't render headers after they are sent to the client.
Body:
"[email protected]"]
Any idea what's going on?
Can you please update the module to go to the new version of the campaign monitor api?
https://api.createsend.com/api/v3.1
Your module is currently pointing to
Some documentation in the readme or on a website would help show that the project is mature enough for production use. Auto-generated works for me! Keep up the great work :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.