Dzhubal

Untitled

Feb 4th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var messageText = 'Тут текст сообщения',
  2.     http = new XMLHttpRequest(),
  3.     url = 'https://api.carrotquest.io/v1/users/' + carrotquest.data.user.id + '/startconversation',
  4.     params = 'auth_token=' + carrotquest.data.auth_token + '&id_as_string=true&body='+messageText;
  5. http.open('POST', url, true);
  6. http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=UTF-8');
  7. http.send(params);
  8. http.onreadystatechange = function() {
  9.     if (http.readyState != 4) return;
  10.     if (http.status == 200) {
  11.         var json = JSON.parse(http.responseText);
  12.         carrotquest.messenger.toStateNo();
  13.         carrotquest.messenger.toStateOpened({id: json.data.id});
  14.     };
  15. };
Add Comment
Please, Sign In to add comment