-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbackground.js
43 lines (38 loc) · 1.36 KB
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
chrome.runtime.onMessageExternal.addListener(function(response){
console.log(response.email)
sendEmailToMautic(response.email)
});
// sendEmailToMautic()
function sendEmailToMautic (email) {
var xhr = new XMLHttpRequest();
var url = "http://marketing.bitler.co/api/contacts/";
var access_token = "&access_token=dhf3489dsjfow45ndlfu82034dj"
var params = "?search=" + email
var combo = url + params + access_token;
console.log(combo);
xhr.open("GET", combo, true);
xhr.onreadystatechange = function() {
var responseDing = xhr.response;
var parse = JSON.parse(responseDing);
console.log(parse.contacts[0].id);
UpdateContactToRead(parse.contacts[0].id)
}
xhr.send();
}
function UpdateContactToRead(id) {
var xhr = new XMLHttpRequest();
var url = "http://marketing.bitler.co/api/contacts/";
var access_token = "?access_token=dsfjk4d893j4580udsfiwl5djf8923dn"
var params ={"answeremail":true}
var combo = url + id + '/edit' + access_token
console.log(combo);
xhr.open("PATCH", combo , true);
xhr.setRequestHeader("Content-type","application/json");
// xhr.onreadystatechange = function() {
// var response = xhr.response;
// var parse = JSON.parse(response);
// console.log(parse);
// }
// xhr.send(params);
xhr.send('{"answeremail": true}');
}