玉米广告-dsp对接文档

Contents:

文档更新记录

版本 作者 时间 备注
v0.1 Cui 2015.11.09 创建
v0.2 Cui 2015.12.18 增加ip、ua、mac、设备信息的明文拓展
v0.3 Cui 2016.06.29 修改os大小写、补充广告资源类型、补充 视频广告形式、补充原生广告形式
v1.1 Cui 2016.09.23 增加设备屏幕方向、新增site对象、新增 publisher对象、新增pmp对象、新增deal id对象
v2.0 Cui 2016.11.09 修改link_type为必填、增加请求 中广告形式校验顺序
v2.1 Cui 2016.12.07 补充了imsi明文;添加need_https; 增加原生data.type;增加language
v2.2 Cui 2017.02.14 增加idfv明文;增加结算价格明文
V2.3 ZHEN 2017.07.05 修复原生元素required标示为bool

DSP对接步骤

  1. 获取登陆账号密码
  2. 登陆账号获取token、解密KEY、签名key
  3.  获取proto文件
  1. 开发
  2. 用沙盒自助测试;双方技术做人工核对
  3. 小流量测试:测试展示,点击等上报功能;核对双方数据误差
  4. 上线正式投放

建议广告尺寸

2.插屏推荐规格

  • 横屏
    普通:300*250、标清:600*500、高清:960*640
  • 竖屏
    普通:250*300、标清:500*600、高清:640*960

3.开屏推荐规格

640*960、720*1080

4.视频推荐规格

  • video

    视频格式:MP4 视频时长:15s、30s 视频大小:5M以内

  • 展示图片

    物料格式:图片 尺寸:

    横屏:960*640、竖屏:640*960

5.原生推荐规格

图片尺寸比例:1:1~1:2之间

DSP面板使用说明

面板访问地址:

http://dspcp.adx.yumimobi.com/

在面板上添加设备定向

_images/dsp_filter.png

Warning

如果输入的IMEI或IDFA已存在,则不会添加成功。

Warning

单个dsp最多可设置5条定向设置!

定向设置测试

定向设置添加成功后,将会看到您自己的固定广告。

Note

添加或者删除定向,需要大约1分钟后生效。

JSON接口协议

接口说明

Zplay Adx RTB 总共包含三个步骤。

  1. Zplay Adx向DSP发送广告询价请求(Bid Request)
  2. DSP向Zplay Adx返回出价结果,及广告代码
  3. Zplay Adx向获胜的DSP发送竞价获胜通知

这三个步骤分别对应三个接口,

接口注意事项

  1. ADX 的 RTB API参考通用OpenRTB规范:http://code.google.com/p/openrtb/。大体遵循该规范,但对一些字段有调整
  2. 协议采用 HTTP POST,开启keep-alive,消息格式为json。目前 timeout 设为 360ms。请求头中需要设 Content-Type 为 application/json。
  3. 不出价可以返回HTTP 状态码204 (No Content)
  4. 竞价获胜通知win-notice、展示通知impression-notice、点击通知click-notice均是GET请求
  5. 字段中所有中文必须使用UTF-8编码

请求信息Request

接口信息(BidRequest)

字段名称 类型 默认值 必须 描述
id string   生成的唯一竞价ID,32个字符组成的字符串,由Zplay ADX生成, 例:”57a6a081182 9faf34a78ca625c383ec9”
app object   App对象。应用信息
device object   Device对象。设备信息
imp[] object   Imp对象。但只会填1个元素
bcat[] object   禁用的广告类别, iab详见[IAB §6.1] http://www.iab.net/media/file/OpenRTB_API_Specification_Version2.0_FINAL.PDF
user object   User对象。用户信息
test bool false true标记本次请求是测试请求。当为测试 请求时,DSP需要返回一个带有广告的应答,该应答广告不会被展现给用户,也不会 对该次广告展现计费。适用于联调测试。
ext object   BidRequest的扩展

BidRequest扩展

字段名称 类型 默认值 必须 描述
version int32   当前协议版本号,目前为1
need_https bool false 是否需要https链接的标识,默认为false。当为true时,需要返回的所有素材及追 踪链接必须是https链接

App信息(BidRequest.App)

字段名称 类型 默认值 必须 描述
id string   应用ID,由Zplay Adx生成, 例:”z0000001”
name string   应用名称, 例:”曙光之战”
ver string   应用版本
bundle string   为应用包名,例:”com.zplay.demo”
cat[] string   应用类型,详见[IAB §6.1](http://www.iab.net/media/file/OpenRTB_API_Specification_Version2.0_FINAL.PDF
publisher 对象   [出品方信息](#BID_REQUEST_SITE_PUBLISHER)

设备信息(BidRequest.Device)

字段名称 类型 默认值 必须 描述
os string   只能是”ios”,”android”或”wp”(windows phone)(注意大小写)
dnt bool false 禁止跟踪用户的标志,
osv string   操作系统版本,例:”9.0.1”
make string   生产厂商, 例:”Samsung”
model string   设备型号, 例:”iPhone”
ip string   设备ipv4地址, 例:”8.8.8.8”
ua string   设备user agent, 例:”Mozilla/5.0(iPhone; U; CPU iPhone like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16”
hwv string   设备硬件版本号, 例:”6S”是iPhone 6S的版本号
w int32   设备屏幕宽度,单位:像素, 例:1920
h int32   设备屏幕高度,单位:像素, 例:1080
ppi int32   设备屏幕像素密度,单位:每英寸像素个数,例:400
macsha1 string   mac地址 SHA1;iOS无此字段, android也只是部分机器能拿到
didsha1 string   Android为IMEI SHA1;iOS无此字段,(cdma手机传meid码)
language string   系统语言
dpidsha1 string   Android为ANDROID ID SHA1;iOS为ADID(也叫IDFA) SHA1, 例:”8a319e9fdf05dd8f571b6e0dc2dc2a8263a6974b”
connectiontype 枚举   网络连接类型,0:未知,1:以太网,2:wifi, 3:未知蜂窝网络, 4:2G网络,5:3G网络,6:4G网络,详见proto文件
devicetype 枚举   设备类型,1:移动设备,4:手机, 5:平板
geo 对象   [Geo对象](#BID_REQUEST_DEVICE_GEO),请求设备的经纬度
ext object   设备信息的扩展

设备信息的扩展(BidRequest.Device.Ext)

字段名称 类型 默认值 必须 描述
plmn string   国家运营商编号, 例:”46000”
imei string   imei码明文,(cdma手机传meid码)
imsi string   imsi码明文
idfv string   idfv明文
mac string   mac地址明文
android_id string   Android Id明文
adid string   iOS ADID(也叫IDFA)或Android ADID(国内手机一般没有)
orientation string   设备屏幕方向:1: 竖向,2: 横向

Geo对象(BidRequest.Device.Geo)

字段名称 类型 默认值 必须 描述
lat double   纬度,例:39.9167,是WGS84坐标
lon double   经度,例:116.3833,是WGS84坐标
country string   国家代码,请参见[ISO-3166-1 Alpha-3]( https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3)
region string   国内是省名,美国是州的2个字母缩写,其他国家请参见[ISO-3166-2](https://en.wikipedia.org/wiki/ISO_3166-2)
city string   城市名称, 例:”北京”
LocationType 枚举   位置来源,1:根据gps位置,2:根据IP, 3:用户提供,其他详见proto文件
ext object   Geo的扩展

Geo对象扩展(BidRequest.Device.Geo.Ext)

字段名称 类型 默认值 必须 描述
accu int32 0 精度,请参见[Decimal degrees](https://en.wikipedia.org/wiki/Decimal_degrees)
street string   街道名称, 例:”知春路”

曝光信息(BidRequest.Imp)

字段名称 类型 默认值 必须 描述
id string   曝光ID
bidfloor double   底价,单位是分
bidfloorcur string “CNY” 报价货币单位,目前只支持人民币:”CNY”,美元:”USD”
instl bool false 是否为全插屏广告,true表示全插屏,false表示不是全插屏
banner 对象   banner对象
video 对象   video对象
native 对象   native对象, 下面包含BidRequest_Imp_Native
pmp 对象   pmp对象, 只有在pmp交易模式时才存在
tagid string   广告位id
ext object   曝光信息的扩展

曝光信息扩展(BidRequest.Imp.Ext)

字段名称 类型 默认值 必须 描述
is_splash_screen bool false 是否为开屏广告,true表示开屏,false表示非开屏
inventory_types int[] [1] 支持的素材类型数组, 1:图片,2:图文,3:视频,4:html5,5:文本, 6:原生, 7:html5 url, 即一个指向html5素材页面的url。如果为空,则默认只支持1:图片
ad_type int 0 广告类型,0:banner,1:插屏,2:开屏,3:原生,4:视频;255:unknown

横幅信息(BidRequest.Impression.Banner)

字段名称 类型 默认值 必须 描述
w int32   广告位宽度
h int32   广告位高度
pos 枚举 0 广告位位置,0:未知,4:头部,5:底部,6:侧边栏,7:全屏,其他详见proto文 件

视频(BidRequest.Impression.Video)

字段名称 类型 默认值 必须 | 描述
mimes array   是 | 支持的视频类型
protocols array   支持的视频响应协议
minduration int32   最短时间,单位:秒
maxduration int32   最长时间,单位:秒
w int32   广告位宽度
h int32   广告位高度
pos 枚举 0 广告位位置,0:未知,4:头部,5:底部,6:侧边栏,7:全屏,其他详见proto文件

原生广告(BidRequest.Impression.BidRequest_Imp_Native)

字段名称 类型 默认值 必须 描述
RequestOneof 对象   BidRequest_Imp_Native_RequestNative

原生广告BidRequest_Imp_Native_RequestNative(BidRequest_Imp_Native.BidRequest_Imp_Native_RequestNative)

字段名称 类型 默认值 必须 描述
RequestNative 对象   BidRequest_Imp_Native_RequestNative

原生广告NativeRequest(BidRequest_Imp_Native_RequestNative.NativeRequest)

字段名称 类型 默认值 必须 描述
layout int   原生广告布局样式,2:应用墙,3:信息流,5:走马灯,其他请参看IAB openrtb标准
assets array   原生广告元素列表

原生广告Asset(NativeRequest.Asset)

字段名称 类型 默认值 必须 描述
id int   元素id
required bool false 广告元素是否必须,true:必须,flase:可选
AssetOneof 对象   原生素材对象,包含Asset_Image,Asset_Title,Asset_Data三种类型

原生广告Asset_Image(NativeRequest.Asset.Asset_Image)

字段名称 类型 默认值 必须 描述
Img 对象   image元素

原生广告Asset_Title(NativeRequest.Asset.Asset_Title)

字段名称 类型 默认值 必须 描述
Title 对象   title元素

原生广告Asset_Data(NativeRequest.Asset.Asset_Data)

字段名称 类型 默认值 必须 描述
Data 对象   Data对象

原生广告Image(NativeRequest.Asset.Image)

字段名称 类型 默认值 必须 描述
type int   image元素的类型,1:Icon,2:LOGO, 3:Large image
w int   宽度
h int   高度

原生广告Title(NativeRequest.Asset.Title)

字段名称 类型 默认值 必须 描述
len int   title元素最大文字长度

原生广告Data(NativeRequest.Asset.Data)

字段名称 类型 默认值 必须 描述
type int   数据类型 1: Sponsor 名称,应该包含品牌名称, 2: 描述, 3: 打分, 4:点赞个 数,5:下载个数,6:产品价格, 7:销售价格,往往和前者结合,表示折扣价,8 :电话, 9:地址, 10:描述2, 11:显示的链接, 12:行动按钮名称,1001:视 频url,1002:评论数
len int   data元素最大长度

Pmp对象(BidRequest.Impression.Pmp)

字段名称 类型 默认值 必须 描述
private_auction bool   始终为true
deals array   [Deal对象](#BID_REQUEST_IMP_PMP_DEAL)数组

Deal对象(BidRequest.Impression.Pmp.Deal)

字段名称 类型 默认值 必须 描述
id string   deal唯一标识
bidfloor double   双方商定的交易价格
bidfloorcur string CNY 交易货币单位
at int 3 交易价格结算方式,1:第一价格,2:第 二价格,3:固定价格,默认为3

用户信息(BidRequest.User)

字段名称 类型 默认值 必须 描述
id string   用户id
yob int32   生日年份,例:1995
gender string   男:”M”, 女:”F”, 其他:”0”
geo 对象   [Geo对象](#BID_REQUEST_DEVICE_GEO), 用户家庭位置
data[] 对象   Data对象,用户的扩展信息

用户扩展信息(BidRequest.User.Data)

字段名称 类型 默认值 必须 描述
segment[] 对象   Segment对象,用户人群属性

用户人群属性信息(BidRequest.User.Data.Segment)

字段名称 类型 默认值 必须 描述
id string   属性id
value string   属性值

Site信息(BidRequest.Site)

字段名称 类型 默认值 必须 描述
id string   网站id
name string   网站名称
domain string   网站域名
cat string[]   网站类别,详见[IAB §6.1](http://www.iab.net/media/file/OpenRTB_API_Specification_Version2.0_FINAL.PDF)
sectioncat string[]   当前频道类别,详见[IAB §6.1](http://www.iab.net/media/file/OpenRTB_API_Specification_Version2.0_FINAL.PDF)
pagecat string[]   当前页面类别,详见[IAB §6.1](http://www.iab.net/media/file/OpenRTB_API_Specification_Version2.0_FINAL.PDF)
page string   当前页面URL地址
ref string   当前页面Referrer URL地址
search string   当前页面的搜索关键词来源
mobile bool ture 是否对移动端浏览效果做过优化,false:未做优化;true:做过优化
keywords string   网页关键字,可多个,逗号隔离
publisher 对象   [出品方信息](#BID_REQUEST_SITE_PUBLISHER)

出品方信息(BidRequest.Site.Publisher)

字段名称 类型 默认值 必须 描述
id string   出品方id
name string   名称
domain string   出品方顶级网站域名
cat string[]   出品方类别,详见[IAB §6.1](http://www.iab.net/media/file/OpenRTB_API_Specification_Version2.0_FINAL.PDF)

返回信息 (BidResponse)

接口信息(BidResponse)

字段名称 类型 默认值 必须 描述
id string   在BidRequest中传入的id
seatbid[] 对象数组   SeatBid对象,若提出竞价则需提供一个,并且只接受一个
nbr 枚举   未竞价原因,0:未知错误,1:技术错误,2:无效请求,4:可疑的伪造流量,5:数据中心代理服务器ip,6:不支持设备, 7:被屏蔽媒体,8:不匹配的用户,其他请参看proto文件

SeatBid信息(BidResponse.SeatBid)

字段名称 类型 默认值 必须 描述
bid[] 对象数组   Bid对象,只接受一个

Bid信息(BidResponse.SeatBid.Bid)

字段名称 类型 默认值 必须 描述
id string   由DSP提供的竞价id
impid string   曝光id
price double   出价,单位为分,不能低于曝光最低价格,否则会被当做无效应答。目前只支持人民币
adid string   物料ID,由DSP提供。DSP必须保证如果adid相同,则物料的所有字段相同(除了nurl、clkurl、imptrackers、clktrackers)。如果DSP提供的adid满足以下条件会受 到惩罚:1、提交过多不同的adid;2、相同adid的其他字段不同
nurl string   竞价获胜通知url,win notice url, GET方法调用。可以使用[宏](#BID_MACRO)。推荐使用[曝光监测链接](#BID_WIN_NOTICE)来获取获胜通知。
bundle string   为应用为包名,例:”com.zplay.demo”
iurl string   广告素材的图片URL。banner广告必填
w int32   素材宽度, 当给出的广告素材尺寸与广告位尺寸不完全一致时,素材宽高信息必须给出。
h int32   素材高度
cat string[]   广告类别,详见[IAB §6.1](http://www.iab.net/media/file/OpenRTB_API_Specification_Version2.0_FINAL.PDF)
ext string   bid信息的扩展
adm string   广告物料,目前只在视频广告时使用。 视频素材必须符合VAST 3.0规范,请参看[VAST 3.0 标准](http://www.iab.com/wp-content/uploads/2015/06/VASTv3_0.pdf)
AdmOneof 对象   原生广告对象
dealid string   deal id,只有在pmp交易时才需要

Bid信息的扩展(BidResponse.SeatBid.Bid.Ext)

字段名称 类型 默认值 必须 描述
app_ver string   app推广广告的话,需要提供app的版本号
clkurl string   广告点击跳转地址,允许使用[宏](#BID_MACRO),例http://www.zplay.cn/ad/{AUCTION_BID_ID}
imptrackers[] string[]   曝光追踪地址,允许有多个追踪地址,允许使用[宏](#BID_MACRO)
clktrackers[] string[]   点击追踪地址,允许有多个追踪地址,允许使用[宏](#BID_MACRO)
html_snippet string   html广告代码
inventory_type int 1 广告资源类型, 1:图片,2:图文,3:视频 ,4:html5,5:文本, 6:原生, 7:html5 url, 即一个指向html5素材页面的url
title string   图文广告中的标题
desc string   图文广告中的描述
action int 1 广告动作类型, 1: 在app内webview打开目标链接, 2: 在系统浏览器打开目标链 接, 3:打开地图,4: 拨打电话,5:播放视频, 6:App下载
download_file_name string   下载文件名,动作类型为下载类型时需要

原生广告AdmOneof

字段名称 类型 默认值 必须 描述
AdmNative 对象   原生广告NativeResponse

原生广告Native(NativeResponse)

字段名称 类型 默认值 必须 描述
assets array   原生广告元素列表
link 对象   Link对象,目标链接,默认链接对象,当a ssets中不包括link对象时,使用此对象
imptrackers array   曝光追踪地址数组

原生广告Asset(NativeResponse.Asset)

字段名称 类型 默认值 必须 描述
id int   广告元素ID
title 对象   文字元素
img 对象   图片元素
data 对象   其他数据元素
link 对象   Link对象,点击地址

原生广告Title(NativeResponse.Asset.Title)

字段名称 类型 默认值 必须 描述
text string   title元素的内容文字

原生广告Image(NativeResponse.Asset.Image)

字段名称 类型 默认值 必须 描述
url string   image元素的URL地址
w int   宽度,单位像素
h int   高度,单位像素

原生广告Data(NativeResponse.Asset.Data)

字段名称 类型 默认值 必须 描述
label string   数据显示的名称
value string   数据的内容文字

向DSP发送的竞价结果接口(Win Notice)

通过对展示监测链接中特定参数的宏替换,将广告的计费价格发送给赢得竞价的 DSP 平台

PB接口协议

接口说明

Zplay Adx RTB 总共包含三个步骤。

  1. Zplay Adx向DSP发送广告询价请求(Bid Request)
  2. DSP向Zplay Adx返回出价结果,及广告代码
  3. Zplay Adx向获胜的DSP发送竞价获胜通知

这三个步骤分别对应三个接口,

接口注意事项

  1. ADX 的 RTB API参考通用OpenRTB规范:http://code.google.com/p/openrtb/。大体遵循该规范,但对一些字段有调整
  2. 协议采用 HTTP POST,开启keep-alive,消息格式为ProtoBuf。目前 timeout 设为 360ms。请求头中需要设 Content-Type 为 application/x-protobuf。
  3. 不出价可以返回HTTP 状态码204 (No Content)
  4. 竞价获胜通知win-notice、展示通知impression-notice、点击通知click-notice均是GET请求
  5. 字段中所有中文必须使用UTF-8编码

请求信息Request

接口信息(BidRequest)

字段名称 类型 默认值 必须 描述
id string   生成的唯一竞价ID,32个字符组成的字符 串,由Zplay ADX生成, 例:”57a6a081182 9faf34a78ca625c383ec9”
app object   App对象。应用信息,针对移动App广告
device object   Device对象。设备信息
imp[] object   Imp对象数组,从110(表示当前版本为1.1 ,110的后两位为子版本号,前面的表示主 版本号)版协议以后支持多个Imp对象
bcat[] object   禁用的广告类别,iab详见[IAB §6.1](htt p://www.iab.net/media/file/OpenRTB_AP I_Specification_Version2.0_FINAL.PDF)
user object   User对象。用户信息
site object   Site对象。站点信息,用于移动网站广告
test bool false true标记本次请求是测试请求。当为测试 请求时,DSP需要返回一个带有广告的应答 ,该应答广告不会被展现给用户,也不会 对该次广告展现计费。适用于联调测试。
extensions[version] int32   当前协议版本号,目前为110
extensions[need_https] bool false 是否需要https链接的标识,默认为false 。当为true时,需要返回的所有素材及追 踪链接必须是https链接

App信息(BidRequest.App)

字段名称 类型 默认值 必须 描述
id string   应用ID,由Zplay Adx生成, 例:”z000000 1”
name string   应用名称, 例:”曙光之战”
ver string   应用版本
bundle string   为应用包名,例:”com.zplay.demo”
cat[] string   应用类型,详见[IAB §6.1](http://www.i ab.net/media/file/OpenRTB_API_Specifi cation_Version2.0_FINAL.PDF)
publisher 对象   [出品方信息](#BID_REQUEST_SITE_PUBLIS HER)

设备信息(BidRequest.Device)

字段名称 类型 默认值 必须 描述
os string  
只能是”ios”,”android”或”wp”(windows
phone)(注意大小写)
dnt bool false 禁止跟踪用户的标志,
osv string   操作系统版本,例:”9.0.1”
make string   生产厂商, 例:”Samsung”
model string   设备型号, 例:”iPhone”
ip string   设备ipv4地址, 例:”8.8.8.8”
ua string  

设备user agent, 例:”Mozilla/5.0 (iPh one; U; CPU iPhone OS 3_0 like Mac OS

X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16”
hwv string   设备硬件版本号, 例:”6S”是iPhone 6S的 版本号
w int32   设备屏幕宽度,单位:像素, 例:1920
h int32   设备屏幕高度,单位:像素, 例:1080
ppi int32   设备屏幕像素密度,单位:每英寸像素个 数, 例:400
pxratio double   设备屏幕物理像素密度,,例:iPhone 3为 1, iPhone 4为2, iPhone 6S plus为3
macsha1 string   mac地址 SHA1;iOS无此字段, android也 只是部分机器能拿到
didsha1 string   Android为IMEI SHA1;iOS无此字段,(cdm a手机传meid码)
language string   系统语言
dpidsha1 string   Android为ANDROID ID SHA1;iOS为ADID( 也叫IDFA) SHA1, 例:”8a319e9fdf05dd8 f571b6e0dc2dc2a8263a6974b”
connectiontype 枚举   网络连接类型,0:未知,1:以太网,2: wifi, 3:未知蜂窝网络, 4:2G网络,5 :3G网络,6:4G网络,详见proto文件
devicetype 枚举   设备类型,1:移动设备,4:手机, 5: 平板
geo 对象   [Geo对象](#BID_REQUEST_DEVICE_GEO), 请求设备的经纬度
extensions[plmn] string   国家运营商编号, 例:”46000”
extensions[imei] string   imei码明文,(cdma手机传meid码)
extensions[imsi] string   imsi码明文
extensions[idfv] string   idfv明文
extensions[mac] string   mac地址明文
extensions[android_id] string   Android Id明文
extensions[adid] string   iOS ADID(也叫IDFA)或Android ADID(国内 手机一般没有)
extensions[orientation] int   设备屏幕方向:1: 竖向,2: 横向

Geo对象(BidRequest.Device.Geo)

字段名称 类型 默认值 必须 描述
lat double   纬度,例:39.9167,是WGS84坐标
lon double   经度,例:116.3833,是WGS84坐标
country string   国家代码,请参见[ISO-3166-1 Alpha-3]( https://en.wikipedia.org/wiki/ISO_316 6-1_alpha-3)
region string   国内是省名,美国是州的2个字母缩写,其 他国家请参见[ISO-3166-2](https://en.w ikipedia.org/wiki/ISO_3166-2)
city string   城市名称, 例:”北京”
LocationType 枚举  
位置来源,1:根据gps位置,2:根据IP,
3:用户提供,其他详见proto文件
extensions[accu] int32 0 精度,请参见[Decimal degrees](https:/ /en.wikipedia.org/wiki/Decimal_degree s)
extensions[street] string   街道名称, 例:”知春路”

曝光信息(BidRequest.Imp)

字段名称 类型 | 默认值 必须 描述
id string | 曝光ID
bidfloor double | 底价,单位是分
bidfloorcur string | CNY 报价货币单位,目前只支持人民币:”CNY”,美元:”USD”
instl bool | false 是否为全插屏广告,true表示全插屏,false表示不是全插屏
banner 对象 | banner对象
video 对象 | video对象
pmp 对象 | pmp对象, 只有在pmp交易模式时才存在
native 对象 | native对象, 下面包含NativeRequest
tagid string | 广告位id
extensions[is_splash_screen] bool | false 是否为开屏广告,true表示开屏,false表示非开屏
extensions[inventory_types] int[] | [1] 支持的素材类型数组, 1:图片,2:图文,3:视频,4:html5,5:文本,6:原生, 7:html5 url, 即一个指向html5素材页面的url。如果为空,则默认只支持1:图片
extensions[ad_type] int | 0 广告类型,0:banner,1:插屏,2:开屏,3:原生,4:视频;255:unknown

横幅信息(BidRequest.Impression.Banner)

字段名称 类型 默认值 必须 描述
w int32   广告位宽度
h int32   广告位高度
pos 枚举 0 广告位位置,0:未知,4:头部,5:底部,6:侧边栏,7:全屏,其他详见proto文件

视频(BidRequest.Impression.Video)

字段名称 类型 默认值 必须 | 描述
mimes array   是 | 支持的视频类型
protocols array   支持的视频响应协议
minduration int32   最短时间,单位:秒
maxduration int32   最长时间,单位:秒
w int32   广告位宽度
h int32   广告位高度
pos 枚举 0 广告位位置,0:未知,4:头部,5:底部,6:侧边栏,7:全屏,其他详见proto文件

原生广告(BidRequest.Impression.NativeRequest)

字段名称 类型 默认值 必须 描述
layout int   原生广告布局样式,2:应用墙,3:信息 流,5:走马灯,其他请参看IAB openrtb 标准
assets array   原生广告元素列表

原生广告Asset(NativeRequest.Asset)

字段名称 类型 默认值 必须 描述
id int   元素id
required int 0 广告元素是否必须,1:必须,0:可选
title 对象   文字元素
img 对象   图片元素
data 对象   其他数据元素

原生广告Image(NativeRequest.Asset.Image)

字段名称 类型 默认值 必须 描述
type int   image元素的类型,1:Icon,2:LOGO, 3: Large image
w int   宽度
h int   高度

原生广告Title(NativeRequest.Asset.Title)

字段名称 类型 默认值 必须 描述
len int   title元素最大文字长度

原生广告Data(NativeRequest.Asset.Data)

字段名称 类型 默认值 必须 描述
type int   数据类型 1: Sponsor 名称,应该包含品 牌名称, 2: 描述, 3: 打分, 4:点赞个 数,5:下载个数,6:产品价格, 7:销 售价格,往往和前者结合,表示折扣价,8 :电话, 9:地址, 10:描述2, 11:显 示的链接, 12:行动按钮名称,1001:视 频url,1002:评论数
len int   data元素最大长度

Pmp对象(BidRequest.Impression.Pmp)

字段名称 类型 默认值 必须 描述
private_auction bool   始终为true
deals array   [Deal对象](#BID_REQUEST_IMP_PMP_DEAL) 数组

Deal对象(BidRequest.Impression.Pmp.Deal)

字段名称 类型 默认值 必须 描述
id string   deal唯一标识
bidfloor double   双方商定的交易价格
bidfloorcur string CNY 交易货币单位
at int 3 交易价格结算方式,1:第一价格,2:第 二价格,3:固定价格,默认为3

用户信息(BidRequest.User)

字段名称 类型 默认值 必须 描述
id string   用户id
yob int32   生日年份,例:1995
gender string   男:”M”, 女:”F”, 其他:”0”
geo 对象   [Geo对象](#BID_REQUEST_DEVICE_GEO), 用户家庭位置
data[] 对象   Data对象,用户的扩展信息

用户扩展信息(BidRequest.User.Data)

字段名称 类型 默认值 必须 描述
segment[] 对象   Segment对象,用户人群属性

用户人群属性信息(BidRequest.User.Data.Segment)

字段名称 类型 默认值 必须 描述
id string   属性id
value string   属性值

Site信息(BidRequest.Site)

字段名称 类型 默认值 必须 描述
id string   网站id
name string   网站名称
domain string   网站域名
cat string[]   网站类别,详见[IAB §6.1](http://www.i ab.net/media/file/OpenRTB_API_Specifi cation_Version2.0_FINAL.PDF)
sectioncat string[]   当前频道类别,详见[IAB §6.1](http://w ww.iab.net/media/file/OpenRTB_API_Spe cification_Version2.0_FINAL.PDF)
pagecat string[]   当前页面类别,详见[IAB §6.1](http://w ww.iab.net/media/file/OpenRTB_API_Spe cification_Version2.0_FINAL.PDF)
page string   当前页面URL地址
ref string   当前页面Referrer URL地址
search string   当前页面的搜索关键词来源
mobile bool true 是否对移动端浏览效果做过优化,false: 未做优化;true:做过优化
keywords string   网页关键字,可多个,逗号隔离
publisher 对象   [出品方信息](#BID_REQUEST_SITE_PUBLIS HER)

出品方信息(BidRequest.Site.Publisher)

字段名称 类型 默认值 必须 描述
id string   出品方id
name string   名称
domain string   出品方顶级网站域名
cat string[]   出品方类别,详见[IAB §6.1](http://www .iab.net/media/file/OpenRTB_API_Speci fication_Version2.0_FINAL.PDF)

返回信息Response

接口信息(BidResponse)

字段名称 类型 默认值 必须 描述
id string   在BidRequest中传入的id
seatbid[] 对象数组   SeatBid对象,若提出竞价则需提供一个, 并且只接受一个
nbr 枚举   未竞价原因,0:未知错误,1:技术错误 ,2:无效请求,4:可疑的伪造流量,5: 数据中心代理服务器ip,6:不支持设备, 7:被屏蔽媒体,8:不匹配的用户,其他 请参看proto文件

SeatBid信息(BidResponse.SeatBid)

字段名称 类型 默认值 必须 描述
bid[] 对象数组   Bid对象数组,从110版协议以后支持多个B id对象()

Bid信息(BidResponse.SeatBid.Bid)

字段名称 类型 默认值 必须 描述
id string   由DSP提供的竞价id
impid string   曝光id
price double   出价,单位为分,不能低于曝光最低价格 ,否则会被当做无效应答。目前只支持人 民币
adid string   物料ID,由DSP提供。DSP必须保证如果adi d相同,则物料的所有字段相同(除了nurl 、clkurl、imptrackers、clktrackers) 。如果DSP提供的adid满足以下条件会受到 惩罚:1、提交过多不同的adid;2、相同a did的其他字段不同
nurl string   竞价获胜通知url,win notice url, GET方 法调用。可以使用[宏](#BID_MACRO)。推 荐使用[曝光监测链接](#BID_WIN_NOTICE) 来获取获胜通知。
bundle string   为应用包名,例:“com.zplay.demo”
iurl string   广告素材的图片URL。banner广告必填
w int32   素材宽度, 当给出的广告素材尺寸与广告 位尺寸不完全一致时,素材宽高信息必须 给出。
h int32   素材高度
cat string[]   广告类别,详见[IAB §6.1](http://www.i ab.net/media/file/OpenRTB_API_Specifi cation_Version2.0_FINAL.PDF)
adm string   广告物料,目前只在视频广告时使用。 视 频素材必须符合VAST 3.0规范,请参看[VA ST 3.0 标准](http://www.iab.com/wp-co ntent/uploads/2015/06/VASTv3_0.pdf)
native 对象   原生广告对象
dealid string   deal id,只有在pmp交易时才需要
extensions[app_ver] string   app推广广告的话,需要提供app的版本号
extensions[clkurl] string   广告点击跳转地址,允许使用[宏](#BID_M ACRO),例http://www.zplay.cn/ad/{AUCT ION_BID_ID}
extensions[imptrackers][] string[]   曝光追踪地址,允许有多个追踪地址,允 许使用[宏](#BID_MACRO)
extensions[clktrackers][] string[]   点击追踪地址,允许有多个追踪地址,允 许使用[宏](#BID_MACRO)
extensions[html_snippet] string   html广告代码
extensions[inventory_type] int 1 广告资源类型, 1:图片,2:图文,3:视频 ,4:html5,5:文本, 6:原生, 7:html5 u rl, 即一个指向html5素材页面的url
extensions[title] string   图文广告中的标题
extensions[desc] string   图文广告中的描述
extensions[action] int 1 广告动作类型, 1: 在app内webview打开 目标链接, 2: 在系统浏览器打开目标链 接, 3:打开地图,4: 拨打电话,5:播 放视频, 6:App下载
extensions[download_file_name] string   下载文件名,动作类型为下载类型时需要

原生广告Native(NativeResponse)

字段名称 类型 默认值 必须 描述
assets array   原生广告元素列表
link 对象   Link对象,目标链接,默认链接对象,当a ssets中不包括link对象时,使用此对象
imptrackers array   曝光追踪地址数组

原生广告Asset(NativeResponse.Asset)

字段名称 类型 默认值 必须 描述
id int   广告元素ID
title 对象   文字元素
img 对象   图片元素
data 对象   其他数据元素
link 对象   Link对象,点击地址

原生广告Title(NativeResponse.Asset.Title)

字段名称 类型 默认值 必须 描述
text string   title元素的内容文字

原生广告Image(NativeResponse.Asset.Image)

字段名称 类型 默认值 必须 描述
url string   image元素的URL地址
w int   宽度,单位像素
h int   高度,单位像素

原生广告Data(NativeResponse.Asset.Data)

字段名称 类型 默认值 必须 描述
label string   数据显示的名称
value string   数据的内容文字

向DSP发送的竞价结果接口(Win Notice)

通过对展示监测链接中特定参数的宏替换,将广告的计费价格发送给赢得竞价的 DSP 平台

目前支持的宏

字段 含义
{AUCTION_BID_ID} 竞价ID
{AUCTION_BID_PRICE} 最终结算价格,该价格是被加密的,解密方法请参见[结算价格解析方法] (#BID_PRICE_DECRYPT)
{AUCTION_BID_PRICE_NOENC} 最终结算价格,明文
{AUCTION_IMP_ID} 曝光id
{AUCTION_IP} 用户ip
{AUCTION_DID_SHA1} 请参见[设备](#)didsha1字段
{AUCTION_DPID_SHA1} 请参见[设备](#)dpidsha1字段
{AUCTION_IMEI} 明文Imei号
{AUCTION_IMSI} 明文Imsi号
{AUCTION_ANDROID_ID} 明文Android Id
{AUCTION_IDFA} 明文Idfa
{AUCTION_OS} 设备类型,ios或android
{AUCTION_APP_ID} 应用ID
{AUCTION_TIMESTAMP} GMT unix timestamp, 单位为秒
{AUCTION_CLICK_URL} 广告点击跳转URL
{AUCTION_RANDOM_NUM} 随机数,用来保证url不会被客户端缓冲

上报地址宏替换信息

Note

客户端触发上报信息时,会替换点击坐标宏变量,单位为像素。可支持的宏坐标如下:

宏变量 类型 说明
YUMI_ADSERVICE_CLICK_DOWN_X int32 点击落下X坐标
YUMI_ADSERVICE_CLICK_DOWN_Y int32 点击落下Y坐标
YUMI_ADSERVICE_CLICK_UP_X int32 点击离开X坐标
YUMI_ADSERVICE_CLICK_UP_Y int32 点击离开Y坐标

Note

媒体的支持工作在逐步拓展

结算价格解析方法

DSP 获取到的结算价格,是经过加 密后的结算价格,每个 DSP 有一个唯一的结算价格解密密钥, 请联系 Zplay Adx 团队获取,并妥善保管。

约束变量

字段 含义
Psettle 原始价格
Pencrpt 加密的价格
d_key 解密密匙,32字节
i_key 完整性密匙,32字节
time_stamp 时间戳
integrity 完整性签名
side_word 价格加密干扰码,8字节
+ 字符串连接
^ 异或
WebSafeBase64Encode() 标准base64 编码(RFC2045),替换“+”为“-”;“/”为“_”,会省略填补的字符
WebSafeBase64Decode() 标准base64 编码(RFC2045),需要替换“-”为“+”;“_”为“/”,并填补占位符
Eenc 加密后的密文
Esrc 原始密文

解密步骤:

  • 原始密文Esrc 右端补齐’=’ 直到字符串长度为4的倍数为止

  • 用WebSafeBase64Decode解码该字符串,结果应为长度16字节的数据 数据格式如下:

    time_stamp(4) | P:sub:`encrpt`(8) | integrity(4)
    其中time_stamp 为小字节字序的int32 值,是加密价格时的unix time stamp。
  • 使用秘钥d_key对time_stamp, 进行如下操作

    mac = hmac.New(sha1.New, d_key)
    mac.Write(time_stamp)
    side_word = mac.Sum(nil)[:8]
  • 将Pencrpt 与side_word进行按字节异或操作, 得到值既为Psettle , 是小字节字序的float64值, 单位为分

校验步骤

  • 将Psettle 与time_stamp按小字节字序合并为12字节的数据, 用i_key进行如下操作

    mac = hmac.New(sha1.New, i_key)
    mac.Write(Psettle + time_stamp) (并不是数字的相加,而是合并为12字节的数据)
    result = mac.Sum(nil)[:4]
  • 将上一步骤得出的结果,与integrity进行比较, 相等表示校验成功,否则失败。

沙盒面板使用指南

沙盒是用于DSP在测试协议使用的工具

登录地址:http://sandbox.dspcp.adx.yumimobi.com

账号和密码与商务开通的账号、密码一致

操作步骤

1.添加请求接收地址

_images/url_seeting.png

2.创建请求

_images/test_step.png

点击第一步,即可进入请求设置界面

_images/new_req.png

在这里,可设置广告形式、物料格式;如果要支持广告位定向,可在广告位id处填写,以便测试

3.发起请求

_images/test_step.png

点击第二步,即可发起测试请求

说明

1.在沙盒测试,广告形式需要使用如下判断逻辑:传的bidrequest里有video对象,就是视频广告。 有native对象,就是原生广告。 两者都不是的时候 , 看imp对象的instl标志, 为true,且IsSplashScreen扩展为真就是开屏; instl为真,但IsSplashScreen为false,则为插屏。 instl为false则是普通banner。 (instl=false banner; instl=true and extensions[is_splash_screen]=false 插屏; instl=true and extensions[is_splash_screen]=true 开屏)

2.沙盒的面板不显示拓展字段,但对请求和返回解析没有影响

API接口

文档更新记录

版本 作者 时间 备注
0.1 Cui 2015.10.27 创建
0.2 Wei 2015.11.24 添加DSP统计信息接口
0.3 Wei 2016.03.29 上传接口中添加广告类型和广告尺寸的参数
0.4 Qi 2016.03.02 添加DSP投放设置及获取接口
0.5 Wei 2016.09.27 添加前审的广告素材提交api
0.6 Zhen 2016.11.09 删除upload接口;更改upload2审核状态
1.0 Zhen 2017.03.20 rst方式构建新文档

DSP辅助API服务器根地址

物料审核API

方法 格式 编码
HTTP POST JSON UTF-8

提交广告素材api

url: /dsp/api/inventory/upload2
{
    "dsp_token": "d52b426d8d5a4adeb998f1ba0b290014",
    "ad_id": "adid_g72",
    "ad_type": 4,
        "ad_size":"320x50",
    "client_name": "client_32",
    "target_url": "http://target.com/FfAB",
        "file_urls":[
                "http://baidu.com/img/123.jpg"
        ],
    "native": [
        {
            "id": 1,
            "title": {
                "text": "title01"
            }
        },
        {
            "id": 2,
            "img": {
                "url": "http://test.com/test_02.jpg",
                "w": 640,
                "h": 960
            },
            "link": {
                "url": "http://test.com/link_02",
                "type": 2
            }
        },
        {
            "id": 3,
            "data": {
                "label": "label_01",
                "value": "http://test.com/lable_01.jpg"
            }
        },
        {
            "id": 4,
            "data": {
                "label": "label_02",
                "value": "test_02"
            }
        }
    ]
}
字段名称 类型 必须 描述
dsp_token string dsp令牌,可在dsp控制面板,或联系zplay adx业务人员得到
ad_id string 广告id,由dsp生成
ad_type int 广告类型,现在支持的类型有0(banner),1(插屏),2(开屏), 3(原生),4(视频)
ad_size string 广告尺寸,例如”320x50”,格式为”宽x高”,可用尺寸参考adx提供的 广告尺寸文档,原生广告不需要尺寸信息,其他广告形式需要此信息
target_url string 点击广告后的目标url
client_name string 广告主名称
file_urls 数组 广告素材文件数组,当广告类型(ad_type)为视频(4)时,需要一个视频 素材链接(.mp4结尾)和一个图片素材链接(.jpg或.png或.gif结尾), 原生广告不需要此信息,其他广告形式需要
native 数组 原生广告数组,广告类型为原生时,需要此信息,其他广告类型不需要

原生广告Asset

字段名称 类型 必须 描述
id int 广告元素ID
title 对象 文字元素,同一个asset中,仅能包含title,img,data中的一个
img 对象 图片元素,同一个asset中,仅能包含title,img,data中的一个
data 对象 其他数据元素,同一个asset中,仅能包含title,img,data中的一个
link 对象 Link对象,点击地址

原生广告Title

字段名称 类型 必须 描述
text string title元素的内容文字

原生广告Image

字段名称 类型 必须 描述
url string image元素的URL地址
w int 宽度,单位像素
h int 宽度,单位像素

原生广告Data

字段名称 类型 必须 描述
label string 数据显示的名称
value string 数据的内容文字

返回信息说明

字段名称 类型 必须 描述
ret int 0表示成功,其他请参见msg
msg string 失败时,返回详细信息

查询审核未通过的广告信息

url: /dsp/api/inventory/denylist
{
        "dsp_token":"",
        "upload_date":"2015-01-01"
}
字段名称 类型 必须 描述
dsp_token string dsp令牌,可在dsp控制面板,或联系zplay adx业务人员得到
upload_date string 查询的起始时间,将返回该之后所有未审核通过的广告列表; 为空,则返回所有审核未通过的广告列表
{
        "ret":0,
        "msg":"",
        "denied_list" : [
                {
                        "ad_id":"",
                        "deny_reason":""
                }
        ]
}

返回信息说明

字段名称 类型 必须 描述
ret int 0表示成功,其他请参见msg
msg string 失败时,返回详细信息
ad_id string 广告id,由dsp生成
deny_reason string 拒绝原因

查询广告的审核状态

url: /dsp/api/inventory/query_review_state
{
        "dsp_token":"",
        "ads":[
                "1" , "2"
        ]
}
字段名称 类型 必须 描述
dsp_token string dsp令牌,可在dsp控制面板,或联系zplay adx业务人员得到
ads 数组 要查询的广告id数组
{
        "ret":0,
        "msg":"",
        "ads" : [
                {
                        "ad_id":"",
                        "review_state":0,
                        "deny_reason":""
                }
        ]
}

返回信息说明

字段名称 类型 必须 描述
ret int 0表示成功,其他请参见msg
msg string 失败时,返回详细信息
ad_id string 广告id,由dsp生成
review_state int 审核状态, 0:待审核,1:审核通过,2:被拒绝
deny_reason string 拒绝原因

查询DSP统计信息

url: /dsp/api/inventory/query_stat_info
{
        "dsp_token":"",
        "start_time":"",
    "end_time":""
}
字段名称 类型 必须 描述
dsp_token string dsp令牌,可在dsp控制面板,或联系zplay adx业务人员得到
start_time int 要查询的统计信息的起始时间的时间戳,单位为秒
end_time int 要查询的统计信息的结束时间的时间戳,单位为秒
{
        "ret":0,
        "msg":"",
        "stat_info":StatInfo
}

返回信息说明

字段名称 类型 必须 描述
ret int 0表示成功,其他请参见msg
msg string 失败时,返回详细信息
stat_info string 广告id,由dsp生成

StatInfo

{
  "query_count":1,
  "bid_count":1,
  "timeout_count":1,
  "error_count":1,
  "win_count":1,
  "display_count":1,
  "click_count":1,
  "consume_amount":1.3
}
字段名称 类型 必须 描述
query_count int 询价次数
bid_count int 出价次数
timeout_count int 超时次数
error_count int 错误次数
win_count int 竞价获胜次数
display_count int 广告展示次数
click_count int 广告点击次数
consume_amount float 消费金额

DSP投放设置api

url: /dsp/api/setting

为了保证安全性,dsp投放设置api额外增加签名验证,需要在HTTP Header中额外增加以下信息: authorization:{signature} 签名算法: {signature} = md5({SecretKey}+{JsonString})

{SecretKey}:是DSP注册时接受邮件中的“解密秘钥”

{JsonString}:是POST的json字符串

{
        "dsp_token":"c3438279d331467eb8fd7f731b98e517",
        "qps":123,
        "ad_type":[0,1,2,3],
        "device_type":["phone","pad"],
        "connection_type":["wifi", "4G"],
        "os_type":["ios","android"]
}
字段名称 类型 必须 描述
dsp_token string dsp令牌,可在dsp控制面板,或联系zplay adx业务人员得到
qps int qps
ad_type int 广告类型,现在支持的类型有0(banner),1(插屏),2(开屏), 3(原生),4(视频)
device_type string array 设备类型,可选值(phone、pad)
connection_type string array 网络连接类型,可选值(wifi、2G、3G、4G, Unknown)
os_type string array 操作系统类型 可选值(ios、android)

返回信息说明

字段名称 类型 必须 描述
ret int 0表示成功,其他请参见msg
msg string 失败时,返回详细信息

获取DSP投放设置api

url: /dsp/api/get_setting
{
        "dsp_token":"c3438279d331467eb8fd7f731b98e517"
}
字段名称 类型 必须 描述
dsp_token string dsp令牌,可在dsp控制面板,或联系zplay adx业务人员得到

返回信息说明

字段名称 类型 必须 描述
ret int 0表示成功,其他请参见msg
msg string 失败时,返回详细信息
qps int qps
ad_type int 广告类型,现在支持的类型有0(banner),1(插屏),2(开屏), 3(原生),4(视频)
device_type string array 设备类型,可选值(phone、pad)
connection_type string array 网络连接类型,可选值(wifi、2G、3G、4G, Unknown)
os_type string array 操作系统类型 可选值(ios、android)
{
        "ret":0,
        "msg":"",
        "qps":123,
        "ad_type":[0,1,2,3],
        "device_type":["phone","pad"],
        "connection_type":["wifi", "4G"],
        "os_type":["ios","android"]
}

常见问题

Q:流量测试,投放过程中为什么没有收到流量?

A:登陆玉米ADX客户后台,查询以下几项:
  1. 竞价请求的地址是否填写;
  2. 请求流量的QPS是否填写;
  3. 广告类型及尺寸是否勾选;
  4. 设备类型,网络连接类型,操作系统类型是否勾选。

以上项目check完毕,如果还未收到流量,请联系相关运营人员

Q:为什么所收到的流量突然少了?

A:请check以下项
  1. 登陆后台看超时率是否比较高;
  2. 查看QPS是否有调整;
  3. QPS根据广告投放进行自动调节,查看投放是否有减少,投放减少QPS自动降低

以上项目check完毕,如果还未收到流量,请联系相关运营人员

JOSN请求和返回示例

Warning

示例只适用于json协议,系统默认对接都是pb协议,如果要使用以下示例,请在对接前予以说明(否则,下方对接示例不可用)

banner返回示例

{
    "id": "0bts0K1CQgtF0zJA6R1ZzppG4CJ3b4",
    "seatbid": [
        {
            "bid": [
                {
                    "id": "27170321175320259213",
                    "impid": "27170321175320259213",
                    "price": 0.1,
                    "adid": "ac990ea25bca7474c2553679e3dd33c6",
                    "w": 640,
                    "h": 100,
                    "iurl": "http://img.pxene.com/dav/65d106ff-2cb9-4ae7-a2d8-897fe3f05f64/image/37f5e37fb84945bcb4f29bdb6dbce990.jpg",
                    "adm": "",
                    "ext": {
                        "clkurl": "http://e.cn.mozhen.com/r/k=2038947&p=75Y7B&dx=__IPDX__&rt=2&ns=183.16.2.121&ni=__IESID__&v=__LOC__&xa=__ADPLATFORM__&ro=sm&mo=0&m479b824d9a1fd&m2=b2196f839dae8187e6b2c1931ca847f6&m4=__AAID__&m5=__IDFA__&m6=__MAC1__&m6a=__MAC__&o=http://site.pxene.com/minisiteWap/Accord_3h/",
                        "imptrackers": [
                            "http://sapi.wobile.com/phone/notify.php?act=show&log=dspid%3D101%26uniplayid%3D1636400010%26rid%3D27170321175320259213%26adiplay.6%3D1%26slotd%3Dbanner%26ads%3D640x100%26sdkv%3D6%26ts%3D14900900%26ip%3D183.16.2.121",
                            "http://open.aview.cn/agent/openDisplay.do?st=0&uuidEncType=0&sv=0&b4790f0cc46f1fdd6facee9bc1845&aid=SDK201616090411451r7ykol3qo7e0ou&ro=1&ca=0",
                            "http://ip2.pxene.comapid=d2495550-d1a0-4fde-81d4-fdc634451a36&depid=e1aa0807c3d23e49311b73a3580dd77a&nw=1&os=2&tp=1&reqip=183.16.2.121&gp=1156440300&mb=3&op=1&md=MI+3",
                            "http://g.cn.miaozhen.com/x/k=2038947&p=75Y7B&dx=__IPDX__&rt=2&ns=183.16.2.1__IESID__&v=__LOC__&xa=__ADPLATFORM__&mo=0&m0=__OPE006479b824d9a1fd&m2=b2196f839dae8187e6b2c1931ca847f6&m4=__AAID__&m5=__IDFA__&m6=__MAC1__&m6a=__MAC__&o="
                        ],
                        "clktrackers": [
                            "http://api.wanzhu.SDK201616090411451r7ykol3qo7e0ou%26wzid%3D1010009%26pkg%3Dcom.zplay.migupopstar.mi%26did%3D5c8ade2b7a03613126opt%3D46000%26plt%3D1%26slotid%3Dbanner%26ax100%26sdkv%3D6%26ts%3D1490090000%26ip%3D183.16.2.121",
                            "http://open.advew.cn/aid=SDK201616090411451r7ykol3qo7e0ou&ro=1&ca=0",
                            "http://cl2.pxene.com/ic?adx=14&bid=20170321-175320_bidreq_130-1030-NGzw-591&mtype=c&mapid=d2495550-d1a0-4fde-81d4-fdc6344dtype=97&appi23e49311b73a3580dd77a&nw=1&os=2&tp=1&reqip=183.16.2.121&gp=1156440300&mb=3&op=1&md=MI+3&url="
                        ],
                        "title": "",
                        "desc": "",
                        "action": 1,
                        "html_snippet": "",
                        "inventory_type": 1
                    }
                }
            ]
        }
    ]
}

插屏请求示例

{
    "id": "0bum1K1CQfE62Ae9r23W91zl4bip18",
    "imp": [
        {
            "id": "1",
            "banner": {
                "w": 720,
                "h": 1080,
                "pos": 0
            },
            "instl": true,
            "tagid": "zapf7e40c242176f01fd5db1af86146a6de00dde23b",
            "bidfloor": 800,
            "bidfloorcur": "CNY",
            "ext": {
                "is_splash_screen": true,
                "inventory_types": [
                    1
                ],
                "ad_type":1
            }
        }
    ],
    "app": {
        "id": "1007875",
        "name": "QueryViolations",
        "ver": "",
        "bundle": "cn.eclicks.wzsearch"
    },
    "device": {
        "dnt": false,
        "ua": "Mozilla/5.0(Linux;Android6.0.1;OPPOR9sBuild/MMB29M;wv)AppleWebKit/537.36(KHTML,likeGecko)Version/4.0Chrome/46.0.2490.76MobileSafari/537.36",
        "ip": "117.173.83.146",
        "geo": {
            "lat": 31.359089,
            "lon": 103.49656,
            "country": "CHN",
            "region": "四川",
            "city": "成都",
            "type": 2,
            "ext": {
                "accu": 0
            }
        },
        "didsha1": "88206dfa4841569b3b61f27a3775d030cd6104c2",
        "dpidsha1": "1592348a810c27d651b5ef8290e50e7514da2502",
        "make": "",
        "model": "OPPOR9s",
        "os": "android",
        "osv": "6.0.1",
        "w": 1080,
        "h": 1920,
        "ppi": 480,
        "connectiontype": 2,
        "devicetype": 4,
        "macsha1": "c1976429369bfe063ed8b3409db7c7e7d87196d9",
        "ext": {
            "plmn": "46001",
            "imei": "864083031808612",
            "imsi": "",
            "mac": "02:00:00:00:00:00",
            "android_id": "705cce10d9d051a8",
            "adid": "",
            "orientation": 1
        }
    },
    "ext": {
        "version": 1,
        "need_https": false
    }
}

插屏返回示例

{
    "id": "0bsZ061CQfE403tMax38YlB71cvWlH",
    "seatbid": [
        {
            "bid": [
                {
                    "id": "3e56c4f0b81b470196f671c96e1be5d9",
                    "impid": "1",
                    "price": 1100,
                    "adid": "370",
                    "nurl": "http://dsptrack.ad-ex.com/winnotice?requestid=0bsZ061CQfE403tMax38YlB71cvWlH&adgr104.108.146&app_name=VLife&material_type=banner",
                    "adomain": [
                        "http://www.adidas.com.cn/"
                    ],
                    "bundle": "",
                    "iurl": "http://res.ad-mex.com/dspres/upload/20170307/88b58192-c86a-43dc-a4c2-69a5bd84f820.jpg",
                    "cid": "18",
                    "crid": "370",
                    "w": 640,
                    "h": 960,
                    "ext": {
                        "imptrackers": [
                            "http://g.cn.miaozhen.com/x/k=2039081&p=75VMG&dx=__IPDX__&rt=2&ns=223.104.108.146&ni=__IESID__&v=__LOC__&xa=__ADPLATFORM__&mo=0&m0=__OPENUDID__&m0a=__DUID__&m1=bbd424977f85c210&m1a=__ANDROIDID__&m2=0f11e9b670e033f52da2e3a910523cf0&m4=__AAID__&m5=__IDFA__&m6=__MAC1__&m6a=__MAC__&o=",
                            "http://dsptrack.ad-mex.com/adImp?requestid=0bsZ061CQfE403tMax38YlB71cvWlvlife&ip=223.104.108.146&app_name=VLife&material_type=banner&price={AUCTION_BID_PRICE}"
                        ],
                        "clktrackers": [
                            "http://e.cn.miaozhen.com/r/k=2039081&p=75VMG&dx=__IPDX__&rt=2&ns=__IP__&ni=__IESID__&v=__LOC__&xa=__ADPLATFORM__&vo=32d0b8d2a&vr=2&o=http%3A%2F%2Fad.yoho.cn%2Fhtml5%2F2017%2F02%2Fadidas%2Findex.html",
                            "http://dsptrackhp=223.104.108.146&app_name=VLife&material_type=banner"
                        ],
                        "clkurl": "http://ad.yoho.cn/html5/2017/02/adidas/index.html"
                    }
                }
            ]
        }
    ]
}

原生请求示例

{
    "id": "39mqjw1CLysK1DEPnF0bRCBk1J5pAa",
    "imp": [
        {
            "id": "1",
            "banner": {
                "w": 448,
                "h": 252,
                "pos": 0
            },
            "tagid": "zap89a83f01f05a7fd761428593a13dd4093c3a5216",
            "bidfloor": 100,
            "bidfloorcur": "CNY",
            "native": {
                "RequestOneof": {
                    "RequestNative": {
                        "layout": 6,
                        "assets": [
                            {
                                "id": 1,
                                "required": true,
                                "AssetOneof": {
                                    "Title": {
                                        "len": 10
                                    }
                                }
                            },
                            {
                                "id": 3,
                                "required": true,
                                "AssetOneof": {
                                    "Img": {
                                        "type": 3,
                                        "w": 448,
                                        "h": 252
                                    }
                                }
                            },
                            {
                                "id": 2,
                                "required": false,
                                "AssetOneof": {
                                    "Img": {
                                        "type": 2,
                                        "w": 100,
                                        "h": 100
                                    }
                                }
                            },
                            {
                                "id": 4,
                                "required": true,
                                "AssetOneof": {
                                    "Data": {
                                        "type": 2,
                                        "len": 25
                                    }
                                }
                            }
                        ]
                    }
                }
            },
            "ext": {
                "inventory_types": [
                    6
                ],
                "ad_type":3
            }
        }
    ],
    "app": {
        "id": "1007557",
        "name": "快手看片",
        "ver": "",
        "bundle": "com.kandian.vodapp"
    },
    "device": {
        "dnt": true,
        "ua": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
        "ip": "127.0.0.1",
        "didsha1": "4a73c601fe3127dda8a51ec1e4bc874409e58459",
        "dpidsha1": "d0c6d45541dbf207df6f029dd60255ebc9ccff22",
        "make": "CHM-TL00H",
        "model": "CHM-TL00H",
        "os": "android",
        "osv": "4.4.4",
        "w": 720,
        "h": 1280,
        "ppi": 0,
        "connectiontype": 2,
        "devicetype": 1,
        "macsha1": "",
        "ext": {
            "plmn": "46000",
            "imei": "866329025824802",
            "imsi": "",
            "mac": "",
            "android_id": "e2f7602bff92ced8",
            "adid": "",
            "orientation": 2
        }
    },
    "ext": {
        "version": 1,
        "need_https": false
    }
}

原生返回示例

{"id": "0bts0B1CMf2R43Vd873UcMC705VRrv",
    "seatbid": [
        {
            "bid": [
                {
                    "id": "0bts0B1CMf2R43Vd873UcMC705VRrv",
                    "adid": "2017030911271377610",
                    "impid": "zapdd13a671432d4a653e372fa03b3c68971f788a12",
                    "price": 1000,
                    "AdmOneof": {
                        "AdmNative": {
                            "assets": [
                                {
                                    "id": 0,
                                    "img": {
                                        "url": "http://img.momocdn.com/ad/F4/17/F417956B-85EF-4CA2-A033-EA8FF0897B54_L.jpg"
                                    }
                                },
                                {
                                    "id": 1,
                                    "title": {
                                        "text": "掌游天下落地页"
                                    }
                                }
                            ],
                            "link": {
                                "url": "http://www.baidu.com"
                            }
                        }
                    },
                    "ext": {
                        "action": 1,
                        "imptrackers": [
                            "http://test.openad.immomo.com/dsp/zplay/display?tid=0bts0B1C703Hy7Db8DW7Iz8tcp-5SEntL-ansRbe2UqKcPDg7IYFd8s"
                        ],
                        "clktrackers": [
                            "http://test.openad.immomo.com/dsp/zplay/click?tid_PkEvBy4_DRRyZSWEcd6vhogizqCBoLUBPegSZW-rOyicZKz77x-zIgV"
                        ],
                        "inventory_type": 6
                    },
                    "nurl": "http://test.openad.immomo.com/dsp/zplay/win?tid=0bts0B1CMf2R43Vd873UE3HvFKz77x-zIgV&price={AUCTION_BID_PRICE}"
                }
            ]
        }
    ]
}

视频示例

Note

视频请求的inventory_type=3;需要返回vast视频和展示图片两部分,展示图片可在iurl或者html_snippet返回。这里简单那给下adm的vast示例,

<VAST>
  <Ad id="14921137">
    <InLine>
      <AdSystem><![CDATA[ yodao dsp ]]></AdSystem>
      <AdTitle><![CDATA[ video ad ]]></AdTitle>
      <Description><![CDATA[ video ad ]]></Description>
      <Creatives>
        <Creative id="14921137" AdID="14921137" sequence="1">
          <linear>
            <Duration>12</Duration>
            ..
              这里的播放时长要求正整数,否则会解析出错
            <MediaFiles>
              <MediaFile id="14921137"><![CDATA[ http://live.us.sinaimg.cn/002qTVxrjx074BMTTYSI010401000rFi0k01.mp4 ]]></MediaFile>
            </MediaFiles>
            <TrackingEvents>
              <Tracking event="start"><![CDATA[ http://q105x.cop.yodao.com:8090/impplay.s?ext=Ch4wYnNKZjYxQzU3Wnc0OH%2F%2F%2F%2FwGiAQRXSUZJwgEkYjM1MTM5NDYtOWRmNy00MDhjLTg1YTAtN2M3NzFhMGVlMTJj0gEA2gEFNS4wLjE%3D&event_type=205&play_percent=0.0 ]]></Tracking>
              <Tracking event="complete"><![CDATA[ http://qt105x.corp.yodao.com:8090/impplay.s?ext=Ch4wYnNKZjYxQzU3Wnc0OHJ4NlUwellINDIyQnFmdDYQyvQPGMO6HiDTnqQCKLHbjgcwdDoOMTA2LjM4LjEyMC4xMTRA%2BeO8lYUrSAFSBDEzNzhaIGJlN2I5MmEt_type=205&play_percent=1.0 ]]></Tracking>
            </TrackingEvents>
          </linear>
        </Creative>
      </Creatives>
    </InLine>
  </Ad>
</VAST>

价格解密算法示例

Note

可以使用的测试数据:

enckey:ABE53CC1B7FDA2903681192D105A53EC sigkey:da2d9026aa90400cbc9c4db053e65b82 加密价格:ebHrWLBZ_vQ8id_wknHJAw 实际价格:3500

PHP

<?php
/*-------------------------example------------------------------*/
$PriceDec = new PriceDec($encKey, $sigKey);
$price = $PriceDec->decode($enPrice);
var_dump($price);
/*-------------------------example------------------------------*/

class PriceDec
{

    protected $encKey;

    protected $sigKey;

    public function __construct($encKey, $sigKey)
    {
        $this->encKey = hex2bin($encKey);
        $this->sigKey = hex2bin($sigKey);
    }

    public function decode($base64Str)
    {
        $data = $this->base64urlDecode($base64Str);
        if (!$data || strlen($data) != 16) {
            return false;
        }

        $timeMsStamp = substr($data, 0, 4);
        $encPrice = substr($data, 4, 8);
        $sig = substr($data, 12, 4);

        $pad = hex2bin(hash_hmac('sha1', $timeMsStamp, $this->encKey));
        $decPrice = $this->xorBytes($pad, $encPrice, 8);
        $price = unpack('d', $decPrice);

        if (!isset($price[1])) {
            return false;
        }

        $osig = hex2bin(hash_hmac('sha1', $decPrice . $timeMsStamp, $this->sigKey));
        if ($sig != substr($osig, 0, strlen($sig))) {
            return false;
        }

        return $price[1];
    }

    protected function xorBytes($s1, $s2, $length)
    {
        $result = "";
        for ($i = 0; $i < 8; ++ $i) {
            $result .= chr(ord($s1[$i]) ^ ord($s2[$i]));
        }

        return $result;
    }

    protected function base64urlDecode($base64Str)
    {
        $base64Str = str_replace(array('-','_'), array('+','/'), $base64Str);
        $base64Len = strlen($base64Str);
        $pad = 4 - ($base64Len % 4);
        $pad < 4 && $base64Str = str_pad($base64Str, $base64Len + $pad, "=");

        return base64_decode($base64Str);
    }
}

JAVA

import java.io.UnsupportedEncodingException;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.util.Arrays;
import java.nio.ByteBuffer;
import java.util.Base64;
import javax.xml.bind.DatatypeConverter;
import java.math.BigInteger;

class PriceDec
{
    private byte[] encKey;
    private byte[] sigKey;

    public void Price()
    {

    }

    public void setEncKey(String encKey)
    {
        this.encKey = hex2bin(encKey);
    }

    public void setSigKey(String sigKey)
    {
        this.sigKey = hex2bin(sigKey);
    }

    public double decode(String base64Str)
    {
        byte[] temp = base64UrlDecode(base64Str);

        if (temp.length != 16) {
            throw new RuntimeException("base64UrlDecode string length less 16");
        }

        byte[] timeStamp = new byte[4];
        byte[] encPrice = new byte[8];
        byte[] sig = new byte[4];

        timeStamp = Arrays.copyOfRange(temp,0,4);
        encPrice = Arrays.copyOfRange(temp, 4,12);
        sig = Arrays.copyOfRange(temp, 12,16);

        byte[] pad = hex2bin(hmac_sha1(timeStamp, this.encKey));
        byte[] decPrice = xorBytes(pad, encPrice, 8);

        double d = byteArrToDouble(decPrice);

        int i=0;
        byte[] calByte = new byte[12];
        for (i=0;i<8;i++) {
            calByte[i] = decPrice[i];
        }
        for (i=0;i<4;i++) {
            calByte[8+i] = timeStamp[i];
        }

        byte[] osig = hex2bin(hmac_sha1(calByte, this.sigKey));
        byte[] compareSig = Arrays.copyOfRange(osig, 0,4);

        if (!Arrays.equals(sig, compareSig)) {
            throw new RuntimeException("sig not equal");
        }

        return d;
    }

    public byte[] xorBytes(byte[] padStr, byte[] encPrice, int n)
    {
        int i;
        byte[] retArr = new byte[n];
        for (i=0;i<n;i++) {
            retArr[i] = (byte)(padStr[i]^encPrice[i]);
        }
        return retArr;
    }

    public byte[] base64UrlDecode(String base64Str)
    {
        base64Str = base64Str.replaceAll("-", "+");
        base64Str = base64Str.replaceAll("_", "/");
        int length = base64Str.length();
        int pad = 4-(length%4);
        int i;
        for (i=0;i<pad;i++) {
            base64Str += "=";
        }
        byte[] bytes = base64Str.getBytes();
        byte[] decoded = Base64.getDecoder().decode(base64Str);
        return decoded;
    }

    public double byteArrToDouble(byte[] b) {
        long l;
        l = b[0];
        l &= 0xff;
        l |= ((long) b[1] << 8);
        l &= 0xffff;
        l |= ((long) b[2] << 16);
        l &= 0xffffff;
        l |= ((long) b[3] << 24);
        l &= 0xffffffffl;
        l |= ((long) b[4] << 32);
        l &= 0xffffffffffl;
        l |= ((long) b[5] << 40);
        l &= 0xffffffffffffl;
        l |= ((long) b[6] << 48);
        l &= 0xffffffffffffffl;
        l |= ((long) b[7] << 56);
        return Double.longBitsToDouble(l);
    }

    public byte[] hex2bin(String hex) {
        char[] hex2char = hex.toCharArray();
        byte[] bytes = new byte[hex.length() / 2];
        int temp;
        for (int i = 0; i < bytes.length; i++) {
            temp = Character.digit(hex2char[2 * i], 16) * 16;
            temp += Character.digit(hex2char[2 * i + 1],16);
            bytes[i] = (byte) (temp & 0xff);
        }
        return bytes;
    }

    private String hmac_sha1(byte[] value, byte[] key) {
        try {
            byte[] keyBytes = key;
            SecretKeySpec signingKey = new SecretKeySpec(keyBytes, "HmacSHA1");
            Mac mac = Mac.getInstance("HmacSHA1");
            mac.init(signingKey);
            byte[] rawHmac = mac.doFinal(value);
            String hexBytes = DatatypeConverter.printHexBinary(rawHmac);
            return hexBytes;
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}


/**----------------begin使用范例---------------------**/
public class pricedec{
    public static void main(String args[]) {

        PriceDec p = new PriceDec();
        p.setEncKey($encKey);
        p.setSigKey($sigKey);

        String base64Str = $enPrice;
        System.out.println(p.decode(base64Str));
    }
}
/**----------------end  使用范例---------------------**/

golang

package main

import (
        "bytes"
        "crypto/hmac"
        "crypto/sha1"
        "encoding/base64"
        "encoding/binary"
        "encoding/hex"
        "errors"
        "fmt"
        "strings"
)

func main() {
        fmt.Println(Decode("这是dec_key", "这是sig_key", "这是price_enc"))
}

func Decode(dec_key, sig_key, price_enc string) (float64, error) {
        data, err := base64url_decode(price_enc)
        if err != nil {
                return 0, err
        }

        if len(data) != 16 {
                return 0, errors.New("Illegal base64 string")
        }

        time_ms_stamp_bytes := data[:4]
        enc_price := data[4:12]
        sig := data[12:16]

        dec_key_bytes := hex2bin(dec_key)

        pad := sha1_hmac(time_ms_stamp_bytes, dec_key_bytes)
        dec_price := xor_bytes(pad, enc_price, 8)

        var price float64

        dec_price_buf := bytes.NewBuffer(dec_price)
        binary.Read(dec_price_buf, binary.LittleEndian, &price)

        //校验
        sig_key_bytes := hex2bin(sig_key)
        osig := sha1_hmac(append(dec_price, time_ms_stamp_bytes...), sig_key_bytes)
        if bytes.Compare(sig, osig[:len(sig)]) == 0 {
                //校验成功
                return price, nil
        }

        return price, errors.New("signature is illegal")
}

func xor_bytes(b1, b2 []byte, length int) []byte {
        new_b := make([]byte, length)
        for i := 0; i < length; i++ {
                new_b[i] = b1[i] ^ b2[i]
        }
        return new_b
}

func hex2bin(s string) []byte {
        ret, _ := hex.DecodeString(s)
        return ret
}

func sha1_hmac(data, key []byte) []byte {
        mac := hmac.New(sha1.New, key)
        mac.Write(data)
        return mac.Sum(nil)
}

func base64url_encode(data []byte) string {
        ret := base64.StdEncoding.EncodeToString(data)
        return strings.Map(func(r rune) rune {
                switch r {
                case '+':
                        return '-'
                case '/':
                        return '_'
                }

                return r
        }, ret)
}

func base64url_decode(s string) ([]byte, error) {
        base64Str := strings.Map(func(r rune) rune {
                switch r {
                case '-':
                        return '+'
                case '_':
                        return '/'
                }

                return r
        }, s)

        if pad := len(base64Str) % 4; pad > 0 {
                base64Str += strings.Repeat("=", 4-pad)
        }

        return base64.StdEncoding.DecodeString(base64Str)
}

C#

using System;
using System.Linq;
using System.Security.Cryptography;

class demo
{
        public static void Main(string[] args)
        {
                PriceDec a = new PriceDec();
                Console.WriteLine(a.decode($encKey,$sigKey,$enPrice));
                Console.ReadKey(true);
        }
}

public class PriceDec
{

        public double decode(string enc_key, string sig_key, string price)
        {
                byte[] data = this.base64UrlDecode(price);
                if (data==null|| data.Length != 16)
                {
                        throw new ArgumentException("The price is not a valid string");
                }

                byte[] encKey = hex2Bin(enc_key);
                byte[] sigKye = hex2Bin(sig_key);

                byte[] timeMsStamp = data.Take(4).ToArray();
                byte[] encPrice = data.Skip(4).Take(8).ToArray();
                byte[] sig = data.Skip(12).Take(4).ToArray();

                byte[] pad = hash_hmac(timeMsStamp, encKey);
                byte[] dec_price= xorBytes(pad, encPrice, 8);

                byte[] osigData = new byte[dec_price.Length + timeMsStamp.Length];
                dec_price.CopyTo(osigData,0);
                timeMsStamp.CopyTo(osigData, dec_price.Length);
                byte[] osig = hash_hmac(osigData, sigKye);

                if(!sig.SequenceEqual(osig.Take(4).ToArray())){
                        throw new ArgumentException("The price is not a complete string");
                }

                return BitConverter.ToDouble(dec_price, 0);
        }

        private byte[] hex2Bin(string hexdata)
        {
                if (hexdata == null)
                        throw new ArgumentNullException("hexdata");
                if (hexdata.Length % 2 != 0)
                        throw new ArgumentException("hexdata should have even length");

                byte[] bytes = new byte[hexdata.Length / 2];
                for (int i = 0; i < hexdata.Length; i += 2)
                        bytes[i / 2] = (byte)(HexValue(hexdata[i]) * 0x10
                                              + HexValue(hexdata[i + 1]));
                return bytes;
        }

        static int HexValue(char c)
        {
                int ch = (int)c;
                if (ch >= (int)'0' && ch <= (int)'9')
                        return ch - (int)'0';
                if (ch >= (int)'a' && ch <= (int)'f')
                        return ch - (int)'a' + 10;
                if (ch >= (int)'A' && ch <= (int)'F')
                        return ch - (int)'A' + 10;
                throw new ArgumentException("Not a hexadecimal digit.");
        }


        private byte[] hash_hmac(byte[] signatureString, byte[] secretKey, bool raw_output = false)
        {
                HMACSHA1 hmac = new HMACSHA1(secretKey);
                hmac.ComputeHash(signatureString);
                return hmac.Hash;
        }

        protected byte[] xorBytes(byte[] s1, byte[] s2, int length)
        {
                byte[] result = new byte[length];
                for (int i = 0; i < length; i++)
                {
                        result[i] = Convert.ToByte((int)s1[i] ^  (int)s2[i]);
                }
                return result;
        }

        protected byte[] base64UrlDecode(string base64Str)
        {
                base64Str = base64Str.Replace("-", "+");
                base64Str = base64Str.Replace("_", "/");
                int base64Len = base64Str.Length;
                int pad = 4 - (base64Len % 4);
                if (pad < 4) base64Str = base64Str.PadRight(base64Len + pad, '=');
                return Convert.FromBase64String(base64Str);
        }
}