我正在尝试在我自己的 AWS 服务器上实施 Prebid S2S (Java) 标头投标,下面是客户端代码(用于测试目的的课程不是真正的标头投标):
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
googletag.cmd.push(function () {
googletag.pubads().disableInitialLoad();
});
var pbjs = pbjs || {};
pbjs.que = pbjs.que || [];
var sizes = [
[300, 250]
];
var PREBID_TIMEOUT = 1000;
var FAILSAFE_TIMEOUT = 3000;
var adUnits = [{
code: '/19968336/header-bid-tag-2',
mediaTypes: {
banner: {
sizes: sizes
}
},
bids: [{
bidder: 'appnexus',
params: {
placementId: 13144370
}
}]
}];
pbjs.que.push(function () {
pbjs.setConfig({
debug: true,
s2sConfig: {
adapter: 'prebidServer',
endpoint: "http://openbidding-env.eba-gxjapuw9.us-west-2.elasticbeanstalk.com/openrtb2/auction",
// syncEndpoint: syncEndpoint,
enabled: true,
accountId: '1', // replace this with your account id
bidders: ['appnexus']
// timeout: 3000
}
});
pbjs.addAdUnits(adUnits);
pbjs.requestBids({
bidsBackHandler: initAdserver,
timeout: PREBID_TIMEOUT
});
});
function initAdserver() {
if (pbjs.initAdserverSet) return;
pbjs.initAdserverSet = true;
googletag.cmd.push(function () {
pbjs.setTargetingForGPTAsync && pbjs.setTargetingForGPTAsync();
googletag.pubads().refresh();
});
}
setTimeout(function () {
initAdserver();
}, FAILSAFE_TIMEOUT);
$(document).ready(function () {
});
googletag.cmd.push(function () {
googletag.defineSlot('/19968336/header-bid-tag-2', sizes, 'div-1')
.addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
当我禁用 s2s 时代码工作正常,但是当我启用它时,显示的是谷歌默认测试广告“所有投标人花费了太长时间”而不是 Prebid 测试广告,我不知道我的代码有什么问题。服务器端是否需要进行任何更改?
下面是邮递员的响应,这意味着服务器正在运行并且工作正常。
发布:openbidding-env.eba-gxjapuw9.us-west-2.elasticbeanstalk.com/openrtb2/auction
请求正文:
{
"id": "some-request-id",
"test": 1,
"site": {
"page": "prebid.org"
},
"imp": [{
"id": "some-impression-id",
"banner": {
"format": [{
"w": 600,
"h": 500
}, {
"w": 300,
"h": 600
}]
},
"ext": {
"appnexus": {
"placementId": 12883451
}
}
}],
"tmax": 500
}
回复:
{
"id": "some-request-id",
"seatbid": [],
"cur": "USD",
"nbr": 0,
"ext": {
"debug": {
"resolvedrequest": {
"id": "some-request-id",
"imp": [
{
"id": "some-impression-id",
"banner": {
"format": [
{
"w": 600,
"h": 500
},
{
"w": 300,
"h": 600
}
]
},
"ext": {
"prebid": {
"bidder": {
"appnexus": {
"placementId": 12883451
}
}
}
}
}
],
"site": {
"page": "prebid.org",
"ext": {
"amp": 0
}
},
"device": {
"ua": "PostmanRuntime/7.26.8",
"ip": "111.88.63.85"
},
"test": 1,
"at": 1,
"tmax": 500,
"cur": [
"USD"
],
"source": {
"tid": "03e5ae46-b985-46b1-9a6d-af06d056d6bb"
}
}
},
"responsetimemillis": {},
"tmaxrequest": 500,
"prebid": {
"auctiontimestamp": 1641290094554
}
}
}