重要提示:示例中所述的 Protobuf 消息在此处以人类可读的文本表示。不过,消息并非以这种方式通过线路发送。使用 Google 或 OpenRTB Protobuf 格式时,系统只接受序列化的 BidResponse 消息。
您可以使用以下 C++ 代码创建和序列化 BidResponse 消息:
BidResponse bid_response;
// fill in bid response with bid information
string post_response;
if (bid_response.SerializeToString(&post_response)) {
// respond to the POST with post_response as the content
} else {
// return an error to the POST
}
id:"96Z599PGNvp7Mr99138Fm0"seatbid{bid{id:"NQb32Ge7Rtt84wFn2p8"impid:"1"price:0.153584adid:"test_creative_id_272596"adomain:"google.com"crid:"test_creative_id_272596"cat:"IAB13-7"burl:"https://test.com/imp?id=123456"adm_native{ver:"1.2"assets{id:1required:truetitle{text:"Luxury Mars Cruises"}}assets{id:2required:truedata{value:"Visit the planet in a luxury spaceship."}}assets{id:3required:falsedata{value:"Book today"}}assets{id:4required:truedata{value:"Galactic Luxury Cruises"}}assets{id:5required:trueimg{url:"https://native.test.com/image?id=123456"w:1200h:627}}link{url:"https://www.google.com"}eventtrackers{event:IMPRESSIONmethod:IMGurl:"https://test.com/event?id=123456"}privacy:"https://adssettings.google.com/whythisad?source=display&reasons=OMITTED"}[com.google.doubleclick.bid]{ad_choices_destination_url:"https://test.com/preferences"billing_id:29846056590dsa{behalf:"TEST_ADVERTISER"paid:"TEST_PAYING_ENTITY"adrender:false}}}bid{id:"4vwb23qm6iqU6w6G978"impid:"1"price:0.153584adid:"test_creative_id_272596"adomain:"google.com"crid:"test_creative_id_272596"cat:"IAB21"burl:"https://test.com/imp?id=123456"adm_native{ver:"1.2"assets{id:1required:truetitle{text:"Luxury Mars Cruises"}}assets{id:2required:truedata{value:"Visit the planet in a luxury spaceship."}}assets{id:3required:falsedata{value:"Book today"}}assets{id:4required:truedata{value:"Galactic Luxury Cruises"}}assets{id:5required:trueimg{url:"https://native.test.com/image?id=123456"w:1200h:627}}link{url:"https://www.google.com"}eventtrackers{event:IMPRESSIONmethod:IMGurl:"https://test.com/event?id=123456"}privacy:"https://adssettings.google.com/whythisad?source=display&reasons=OMITTED"}[com.google.doubleclick.bid]{ad_choices_destination_url:"https://test.com/preferences"dsa{behalf:"TEST_ADVERTISER"paid:"TEST_PAYING_ENTITY"adrender:false}}}seat:"4528:1161:591635"group:false}bidid:"hgu4ev7j-ZK929XM0-79f7-0A23O0VN2CFC"cur:"USD"
OpenRTB JSON
显示示例
{"id":"96Z599PGNvp7Mr99138Fm0","seatbid":[{"bid":[{"id":"NQb32Ge7Rtt84wFn2p8","impid":"1","price":0.153584,"adid":"test_creative_id_272596","adomain":["google.com"],"crid":"test_creative_id_272596","cat":["IAB13-7"],"burl":"https://test.com/imp?id=123456","ext":{"ad_choices_destination_url":"https://test.com/preferences","billing_id":"29846056590","dsa":{"behalf":"TEST_ADVERTISER","paid":"TEST_PAYING_ENTITY","adrender":0}},"adm":"{\"ver\":\"1.2\",\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"text\":\"Luxury Mars Cruises\"}},{\"id\":2,\"required\":1,\"data\":{\"value\":\"Visit the planet in a luxury spaceship.\"}},{\"id\":3,\"required\":0,\"data\":{\"value\":\"Book today\"}},{\"id\":4,\"required\":1,\"data\":{\"value\":\"Galactic Luxury Cruises\"}},{\"id\":5,\"required\":1,\"img\":{\"url\":\"https://native.test.com/image?id=123456\",\"w\":1200,\"h\":627}}],\"link\":{\"url\":\"https://www.google.com\"},\"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"https://test.com/event?id=123456\"}],\"privacy\":\"https://adssettings.google.com/whythisad?source=display&reasons=OMITTED\"}"},{"id":"4vwb23qm6iqU6w6G978","impid":"1","price":0.153584,"adid":"test_creative_id_272596","adomain":["google.com"],"crid":"test_creative_id_272596","cat":["IAB21"],"burl":"https://test.com/imp?id=123456","ext":{"ad_choices_destination_url":"https://test.com/preferences","dsa":{"behalf":"TEST_ADVERTISER","paid":"TEST_PAYING_ENTITY","adrender":0}},"adm":"{\"ver\":\"1.2\",\"assets\":[{\"id\":1,\"required\":1,\"title\":{\"text\":\"Luxury Mars Cruises\"}},{\"id\":2,\"required\":1,\"data\":{\"value\":\"Visit the planet in a luxury spaceship.\"}},{\"id\":3,\"required\":0,\"data\":{\"value\":\"Book today\"}},{\"id\":4,\"required\":1,\"data\":{\"value\":\"Galactic Luxury Cruises\"}},{\"id\":5,\"required\":1,\"img\":{\"url\":\"https://native.test.com/image?id=123456\",\"w\":1200,\"h\":627}}],\"link\":{\"url\":\"https://www.google.com\"},\"eventtrackers\":[{\"event\":1,\"method\":1,\"url\":\"https://test.com/event?id=123456\"}],\"privacy\":\"https://adssettings.google.com/whythisad?source=display&reasons=OMITTED\"}"}],"seat":"4528:1161:591635","group":0}],"bidid":"hgu4ev7j-ZK929XM0-79f7-0A23O0VN2CFC","cur":"USD"}
ad{adslot{id:1max_cpm_micros:158000billing_id:41106584355deal_id:1}click_through_url:"google.com"attribute:70buyer_creative_id:"test_creative_id_251451"advertiser_name:"Google"native_ad{headline:"Luxury Mars Cruises"body:"Visit the planet in a luxury spaceship."call_to_action:"Book today"advertiser:"Galactic Luxury Cruises"image{url:"https://native.test.com/image?id=123456"width:1200height:222}app_icon{url:"https://native.test.com/icon?id=123456"width:512height:512}star_rating:4.300000190734863click_link_url:"https://www.google.com"}impression_tracking_url:"https://test.com/imp?id=123456"impression_tracking_url:"https://test.com/imp?id=123456"event_notification_token:"token"skadn{version:"4.0"network:"l6x39K4z"itunesitem:"731305960"sourceapp:"627009739"fidelities{fidelity_type:STOREKIT_RENDERED_ADSnonce:"9216faff-74a9-4b35-badc-66878c35f67c"timestamp:1728975919221signature:"b0USXkmg02Q3v6p301kYOHG36CCOWWdEo52RHRttB9t8PTNi79qL17E4D6h7UeUSuq479oTK13G2Ev34MJlU86C5vY1SMVw2"}fidelities{fidelity_type:VIEW_THROUGH_ADSnonce:"9216faff-74a9-4b35-badc-66878c35f67c"timestamp:1728975919221signature:"4Cf4NH6239z9f3wa8j6420Z7H0UISYxyxN5720444dkq6457I5FY0Jg8bk1xge2P8YgiDp74l2738136v2g1A8D50331IRm0"}source_identifier:1}click_tracking_urls:"https://google.com/rtb/click?imp_id=55d2112c-4947-4da5-bc37-b79ebf4577dd"advertised_app_id:"APP_ID_OMITTED"app_promotion_type:INSTALLS}processing_time_ms:63
[null,null,["最后更新时间 (UTC):2025-02-12。"],[[["Bid responses must be serialized `BidResponse` protocol buffers with the `Content-Type` header set to `application/octet-stream` for Protobuf, and a parsable `BidResponse` is required for each `BidRequest`, while an empty HTTP 204 response signals no bid."],["Each creative needs a unique `crid` (creative ID) limited to 64 bytes, and this ID must be unique across creatives if there are differences in size, declared URL, attributes, vendor types, appearance, behavior, or rendering method."],["Ad characteristics should be declared using `BidResponse.seatbid.bid.apis`, `BidResponse.seatbid.bid.attr`, or `BidResponse.seatbid.bid.ext.attribute`, with specific values indicating VPAID, MRAID, SIZELESS, or PLAYABLE attributes, respectively, and additional attributes from `buyer-declarable-creative-attributes.txt`."],["Responses should remain under 8KB, utilize persistent HTTPS connections with at least a 10-second timeout, and employ `BidResponse.seatbid.bid.burl` or `BidResponse.seatbid.bid.ext.impression_tracking_url` for tracking impressions."],["The `BidResponse` must accurately set creative attributes (`BidResponse.seatbid.bid.attr`), categories (`BidResponse.seatbid.bid.cat`), and advertiser domain (`BidResponse.seatbid.bid.adomain`) or native ad link (`BidResponse.seatbid.bid.adm_native.link.url`), as responses lacking these are discarded."]]],["Applications must respond to each `BidRequest` with a parsable `BidResponse`, using Protobuf or an HTTP 204 for no bids. Creatives are identified by a unique `crid`. Ad attributes, such as VPAID and MRAID, are declared in specific fields. Utilize impression tracking URLs and avoid deprecated fields. Open Bidding bid responses are similar to Authorized Buyers. Ad sizes in the response must match the request. Macros are used in URLs. Publisher requirements are specified in the `BidRequest`. The response must accurately reflect these requirements and provide the accurate ad attributes and links.\n"]]