{"id":1364,"date":"2025-06-11T14:47:18","date_gmt":"2025-06-11T14:47:18","guid":{"rendered":"http:\/\/advtesting.bmcdn3.com\/?page_id=1364"},"modified":"2025-06-11T15:17:07","modified_gmt":"2025-06-11T15:17:07","slug":"test-openrtb","status":"publish","type":"page","link":"https:\/\/advtesting.bitmedia.io\/?page_id=1364","title":{"rendered":"Test OpenRTB"},"content":{"rendered":"\n<div id=\"bm-ad-container\"><\/div>\n<script>\n(async function(){\n  const tmaxVal = 500;\n  if (isNaN(tmaxVal) || tmaxVal < 200 || tmaxVal > 5000) {\n    console.log(\"Invalid tmax value\");\n    return;\n  }\n\n  const impId = \"123456\";\n  if (!impId || typeof impId !== \"string\") {\n    console.log(\"Invalid imp.id\");\n    return;\n  }\n\n  const payload = {\n    \"id\": \"12345\",\n    \"at\": 1,\n    \"cur\": [ \"USD\" ],\n    \"tmax\": tmaxVal,\n    \"imp\": [\n      {\n        \"id\": impId,\n        \"bidfloor\": 0.001,\n        \"bidfloorcur\": \"USD\",\n        \"tagid\": \"33307890_2\",\n        \"secure\": 1,\n        \"exp\": 5000,\n        \"banner\": {\n          \"h\": 250,\n          \"w\": 250\n        }\n      }\n    ],\n    \"site\": {\n      \"id\": \"33307890\",\n      \"domain\": \"https:\/\/test.com\"\n    },\n    \"device\": {\n      \"ua\": navigator.userAgent,\n      \"ip\": \"206.189.193.238\"\n    }\n  };\n\n  let response;\n  try {\n    response = await fetch('https:\/\/cors-anywhere.herokuapp.com\/https:\/\/bmdev.bmcdn5.com\/openrtb?sid=522678362425&ssk=0618d3cca6132179fc8a6f977909c0ea3c7c0b8b8eacb004943033b0f77fc0ea', { \/\/ \u0412\u0438\u043a\u043e\u0440\u0438\u0441\u0442\u043e\u0432\u0443\u0454\u043c\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u0438\u0439 \u043f\u0440\u043e\u043a\u0441\u0456!\n      method: \"POST\",\n      headers: {\n        \"Content-Type\": \"application\/json\"\n      },\n      body: JSON.stringify(payload)\n    });\n  } catch(e) {\n    console.log(\"Request error\", e);\n    return;\n  }\n\n  if (!response.ok) {\n    console.log(\"Bad response status\", response.status);\n    return;\n  }\n\n  let data;\n  try {\n    data = await response.json();\n  } catch(e) {\n    console.log(\"JSON parse error\", e);\n    return;\n  }\n\n  let adm = null;\n  let nurl = null;\n  try {\n    adm = data?.seatbid?.[0]?.bid?.[0]?.adm;\n    nurl = data?.seatbid?.[0]?.bid?.[0]?.nurl;\n  } catch(e){}\n  if (!adm) {\n    console.log(\"No adm in response\", data);\n    return;\n  }\n\n  \/\/ \u0414\u043e\u0434\u0430\u0454\u043c\u043e \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u0438\u0439 \u043f\u0456\u043a\u0441\u0435\u043b\u044c \u0434\u043b\u044f \u0442\u0440\u0435\u043a\u0456\u043d\u0433\u0443 \u0456\u043c\u043f\u0440\u0435\u0441\u0456\u0457, \u044f\u043a\u0449\u043e \u0454 nurl\n  if (nurl) {\n    \/\/ \u042f\u043a\u0449\u043e adm \u2014 \u043f\u043e\u0432\u043d\u0438\u0439 HTML, \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0454\u043c\u043e \u043f\u0456\u043a\u0441\u0435\u043b\u044c \u043f\u0435\u0440\u0435\u0434 <\/body>\n    \/\/ \u042f\u043a\u0449\u043e body \u043d\u0435\u043c\u0430 \u2014 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u0434\u0430\u0454\u043c\u043e \u0432 \u043a\u0456\u043d\u0435\u0446\u044c adm\n    if (adm.indexOf('<\/body>') !== -1) {\n      adm = adm.replace('<\/body>',\n        `<img loading=\"lazy\" src=\"${nurl}\" width=\"1\" height=\"1\" style=\"display:none\" alt=\"\"\/> <\/body>`);\n    } else {\n      adm += `<img loading=\"lazy\" src=\"${nurl}\" width=\"1\" height=\"1\" style=\"display:none\" alt=\"\"\/>`;\n    }\n  }\n\n  const container = document.getElementById(\"bm-ad-container\");\n  if (!container) {\n    console.log(\"Container not found\");\n    return;\n  }\n  const iframe = document.createElement(\"iframe\");\n  iframe.width = 250;\n  iframe.height = 250;\n  iframe.setAttribute(\"frameborder\", \"0\");\n  iframe.setAttribute(\"scrolling\", \"no\");\n  iframe.setAttribute(\"allowtransparency\", \"true\");\n  iframe.setAttribute(\"sandbox\", \"allow-scripts allow-forms allow-popups allow-same-origin allow-top-navigation\");\n  iframe.srcdoc = adm;\n\n  container.appendChild(iframe);\n\n})();\n<\/script>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"_links":{"self":[{"href":"https:\/\/advtesting.bitmedia.io\/index.php?rest_route=\/wp\/v2\/pages\/1364"}],"collection":[{"href":"https:\/\/advtesting.bitmedia.io\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/advtesting.bitmedia.io\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/advtesting.bitmedia.io\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/advtesting.bitmedia.io\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1364"}],"version-history":[{"count":4,"href":"https:\/\/advtesting.bitmedia.io\/index.php?rest_route=\/wp\/v2\/pages\/1364\/revisions"}],"predecessor-version":[{"id":1369,"href":"https:\/\/advtesting.bitmedia.io\/index.php?rest_route=\/wp\/v2\/pages\/1364\/revisions\/1369"}],"wp:attachment":[{"href":"https:\/\/advtesting.bitmedia.io\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1364"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}