Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770
Форумы портала PHP.SU :: Версия для печати :: API regru
Форумы портала PHP.SU » » Вопросы новичков » API regru

Страниц (1): [1]
 

1. shahin - 08 Сентября, 2018 - 23:23:33 - перейти к сообщению
Здравствуйте, подскажите как использовать этот код
CODE (javascript):
скопировать код в буфер обмена
  1. var xhr = new XMLHttpRequest();
  2. var params = {
  3.     "input_data": "{\"domains\":[{\"dname\":\"ya.ru\"},{\"dname\":\"yayayayayaya.ru\"},{\"dname\":\"xn--000.com\"},{\"dname\":\"china.cn\"},{\"dname\":\"ййй.me\"},{\"dname\":\"wwww.ww\"},{\"dname\":\"a.ru\"},{\"dname\":\"qqйй.com\"},{\"dname\":\"rr.ru.com\"}]}",
  4.     "input_format": "json"
  5. };
  6. var form = {
  7.    input_format: "json",
  8.    output_format: "json",
  9.    io_encoding: "utf8",
  10.    input_data: JSON.stringify(params),
  11.    show_input_params: 0,
  12.    username: "test",
  13.    password: "test"
  14. };
  15. xhr.open("POST", "https://api.reg.ru/api/regru2/domain/check");
  16. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
  17. xhr.onreadystatechange = function () {
  18.    if (this.readyState === 4) {
  19.        alert("Status: "+
  20.        this.status+"\nHeaders: "+
  21.        JSON.stringify(this.getAllResponseHeaders())+"\nBody: "+this.responseText);
  22.    }
  23. };
  24. var postData = [];
  25. for (var key in form) {
  26.    if (!form.hasOwnProperty(key)) continue;
  27.    postData.push(key + "=" + form[key]);
  28. }
  29. xhr.send(postData.join("&"));

 

Powered by ExBB FM 1.0 RC1