-
-
Save hadifarnoud/7e5b62775ce7dc9475431ab7f49e64d6 to your computer and use it in GitHub Desktop.
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
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