Skip to content

Instantly share code, notes, and snippets.

@hadifarnoud
Created November 19, 2019 12:57
Show Gist options
  • Save hadifarnoud/7e5b62775ce7dc9475431ab7f49e64d6 to your computer and use it in GitHub Desktop.
Save hadifarnoud/7e5b62775ce7dc9475431ab7f49e64d6 to your computer and use it in GitHub Desktop.
var request = require("request");
var jar = request.jar();
var options = {
method: 'GET',
url: 'https://api.sendinblue.com/v3/reseller/children',
headers: {
'api-key': 'xkeysib-nM8cGXSB6sEjWRa0'
}
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
var json = JSON.parse(body);
json.children.forEach(function (element, index, array) {
if (element.statistics.totalSent==0) {
// console.log('Inactive accounts: ' + element.email);
} else {
// console.log(element.email+" : " +element.statistics.totalSent);
var options2 = {
method: 'GET',
url: 'https://api.sendinblue.com/v3/emailCampaigns',
headers: {
'content-type': 'application/json',
'api-key': element.apiKeys.v3[0].key
}
};
request(options2, function (error, response2, body2) {
if (error) throw new Error(error);
var json2 = JSON.parse(body2);
if (json2.count>0) {
json2.campaigns.forEach(function (e, i, a) {
// see statistics of each campaign
// console.log(e.sender.email + ' ' + Math.round((e.statistics.globalStats.uniqueViews/e.statistics.globalStats.delivered)*100) + '%');
if(e.status=='sent') {
if((e.statistics.globalStats.uniqueViews/e.statistics.globalStats.delivered)*100<3) {
console.log('Suspicious sender: ' + element.companyName + ' campaign: ' +e.subject + ' sent at: '+ e.sentDate + ' Link: ' + e.shareLink);
// console.log('========================================')
// console.log(e)
console.log('e.statistics.campaignStats: '+e.statistics.campaignStats.sent)
}
}
});
} else if (json2.count==1){
if(e.status=='sent') {
if((e.statistics.globalStats.uniqueViews/e.statistics.globalStats.delivered)*100<3) {
console.log('Suspicious sender: ' + element.companyName + ' campaign: ' +e.subject + ' sent at: '+ e.sentDate + ' Link: ' + e.shareLink);
}
}
} else {
// console.log('Normal sender: '+ element.email);
}
}); // end of e forEach
}
}); // end of element forEach
}); // end of request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment