Skip to content

Instantly share code, notes, and snippets.

@muzhig
Created June 25, 2014 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muzhig/3fff28e70745e901fd21 to your computer and use it in GitHub Desktop.
Save muzhig/3fff28e70745e901fd21 to your computer and use it in GitHub Desktop.
RTB request
import json
from pprint import pprint
import requests
rtb_request = {
"id": "1234FcDe",
"imp": [{
"id": "1",
"banner": {
"w": 100, # width - this be used as width parameter in request in case of dynamic size placements
"h": 100, # height - this be used as width parameter in request in case of dynamic size placements
},
"tagid": "1768", # Will be used as placement id in our system, it will be checked and considered as empty bid (204 html status) in case it did not contained a legal placement.
# "bidfloor": 0.0,
}],
"app": { # This or object site should be in request (not both) , this is not used currently on internal ajillionmax implementation.
"id": "123fac",
"name": "Candy Crush",
"bundle": "com.candy.crush",
},
"device": {
"ua": "Mozilla/5.0 (Linux; U; Android 2.2; zh-cn; HTC_Desire_A8181 Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1", # User Agent
"ip": "127.0.0.1",#"145.56.12.12",
},
# "user": { # this is optional , its id will be used for frequency capping , if exists
# "id": "zzz",
# },
}
print json.dumps(rtb_request)
resp = requests.post('http://localhost:8000/ad/rtb/', json.dumps(rtb_request), headers={'X-OPENRTB-VERSION': '2.1'})
print resp.status_code
if resp.status_code == 200:
print resp.json()['seatbid'][0]['bid'][0]['adm']
else:
print resp.content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment