平台API¶
广告主API¶
广告主API 可以实现广告主的创建、编辑、查看。
广告主新建¶
- 请求URL:
/api/advertiser/create- 请求方式:
POST
请求字段:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| advertiserName | string | 是 | dsp 系统的广告主名称 |
| industryId | Long | 是 | 行业ID |
| siteUrl | string | 是 | 网站URL http://或https://开头 |
| address | string | 否 | 广告主公司地址 |
| tel | string | 否 | 广告主电话 |
| contact | string | 否 | 广告主联系人 |
| contactEmail | string | 否 | 广告主联系人Email |
| contactTel | string | 否 | 广告主联系人电话 |
| certificationFile | string | 是 | 营业执照文件 |
请求示例:
1 2 3 4 5 6 7 8 9 10 11 | {
"advertiserName": "广告主测试",
"industryId": 101001,
"siteUrl": "http://www.marketin.cn",
"address": "上海市徐汇区",
"tel": "021-60520945",
"contact": "联系人",
"contactEmail": "info@marketin.cn",
"contactTel": "021-60520945",
"certificationFile": "avatar-ef9260ae-6138-40b4-9252-3523b75a2aa3.jpg"
}
|
返回字段:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| advertiserId | int64 | 是 | SSP 平台上广告主ID |
返回示例:
1 2 3 4 5 6 7 | {
"code": 0,
"message": "成功",
"data": {
"advertiserId": 10236
}
}
|
广告主编辑¶
请求URL:
/api/advertiser/update
请求方式:
POST
请求字段:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| advertiserId | Long | 是 | SSP 平台上广告主ID;例如:10123 |
| advertiserName | string | 是 | dsp 系统的广告主名称 |
| industryId | Long | 是 | 行业ID |
| siteUrl | string | 是 | 网站URL http://或https://开头 |
| address | string | 否 | 广告主公司地址 |
| tel | string | 否 | 广告主电话 |
| contact | string | 否 | 广告主联系人 |
| contactEmail | string | 否 | 广告主联系人Email |
| contactTel | string | 否 | 广告主联系人电话 |
| certificationFile | string | 是 | 营业执照文件 |
请求示例:
1 2 3 4 5 6 7 8 9 10 11 12 | {
"address": "公司地址",
"advertiserId": 1,
"advertiserName": "广告主",
"certificationFile": "avatar-ef9260ae-6138-40b4-9252-3523b75a2aa3.jpg",
"contact": "联系人",
"contactEmail": "联系人Email",
"contactTel": "联系人电话",
"industryId": 101001,
"siteUrl": "http://www.marketin.cn",
"tel": "公司电话"
}
|
返回字段:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| advertiserId | int64 | 是 | SSP 平台上广告主ID |
返回示例:
1 2 3 4 5 6 7 | {
"code": 0,
"message": "成功",
"data": {
"advertiserId": 10236
}
}
|
广告主查询¶
- 请求URL:
/api/advertiser/advertiserId/api/advertiser/advertiserId/Fields(暂未开放)- 请求方式:
GET
请求字段:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| advertiserId | Long | 是 | SSP 平台上广告主ID;例如:10123 |
| fields | json(arry of string) |
否 | 需要获取的字段信息,若不传此字段则认为字段全取. advertiserId,status,advertiserName,industryId,siteUrl, address,tel,contact,contactEmail,contactTel, certificationFile,rejectReason |
返回字段:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| advertiserId | Long | 是 | SSP 平台上广告主ID;例如:10123 |
| status | int | 否 | 状态 1:审核通过/31:未审核/40:审核拒绝 |
| advertiserName | string | 否 | dsp 系统的广告主名称 |
| industryId | Long | 否 | 行业ID |
| siteUrl | string | 否 | 网站URL http://或https://开头 |
| address | string | 否 | 广告主公司地址 |
| tel | string | 否 | 广告主电话 |
| contact | string | 否 | 广告主联系人 |
| contactEmail | string | 否 | 广告主联系人Email |
| contactTel | string | 否 | 广告主联系人电话 |
| certificationFile | string | 否 | 营业执照文件 |
| rejectReason | json | 否 | 审核拒绝原因 |
返回示例:
1 2 3 4 5 6 7 8 9 | {
"code": 0,
"message": "成功",
"data": {
"advertiserId": 10236,
"status": 31,
"rejectReason": reason
}
}
|
广告主列表查询¶
- 请求URL:
/api/advertiser- 请求方式:
GET
请求字段:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| page | int | 否 | 当前页(为空时,默认第一页) |
| pageSize | int | 否 | 每页大小(为空时,默认10条数据) |
| fields | json(arry of string) |
否 | 需要获取的字段信息,若不传此字段则认为字段全取. 返回字段有:advertiserId,status,advertiserName, industryId,siteUrl,address,tel,contact,contactEmail, contactTel,certificationFile,rejectReason |
请求示例:
返回字段:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| advertiserId | int64 | 是 | SSP 平台上广告主ID;例如:10123 |
| status | int | 否 | 状态 1:审核通过/31:未审核/40:审核拒绝 |
| advertiserName | string | 否 | dsp 系统的广告主名称 |
| industryId | Long | 否 | 行业ID |
| siteUrl | string | 否 | 网站URL http://或https://开头 |
| address | string | 否 | 广告主公司地址 |
| tel | string | 否 | 广告主电话 |
| contact | string | 否 | 广告主联系人 |
| contactEmail | string | 否 | 广告主联系人Email |
| contactTel | string | 否 | 广告主联系人电话 |
| certificationFile | string | 否 | 营业执照文件 |
| rejectReason | json | 否 | 审核拒绝原因 |
返回示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | {
"code": 0,
"message": "成功",
"data": {
"list": [
{
"advertiserId": 11,
"status": 30
}
],
"conf": {
"totalNum": 1,
"totalPage": 1,
"pageSize": 10,
"page": 1
}
}
}
|
创意API¶
创意API 可以实现素材的创建、编辑、查看。
创意新建¶
- 请求URL:
/api/creative/inventory/create- 请求方式:
POST
请求字段:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| advertiserId | string | 是 | SSP 平台上广告主ID |
| creativeName | string | 是 | 创意名称 |
| cooperatorCreativeId | string | 是 | 合作平台创意ID |
| creativeType | int | 是 | 创意类型
|
| creativeElement | object | 是 | 创意元素;广告位广告类型对应具体广告元素 见附录 |
| siteUrl | string | 是 | 推广标的物地址 |
| clickTrackingUrl | string | 是 | 点击地址(监控) 注:如果site_url、clickTrackingUrl同时存在, 点击响应地址为clickTrackingUrl |
| impTrackingUrls | array | 否 | 曝光监控地址 |
| click_through_url | string | 是 | 用于广告点击跳转地址 |
| click_tracking_urls | array | 否 | 用于广告异步监测地址 |
creativeElement 对象:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| corporate_name | object | 否 | 商标名称 |
| corporate_img | object | 否 | 商标,图片url |
| image | object | 否 | 图片1 对象 |
| image2 | object | 否 | 图片2 对象 |
| image3 | object | 否 | 图片3 对象 |
| title | object | 否 | 广告文案 |
| description | object | 否 | 广告描述 |
| video | object | 否 | Video url |
title 对象:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| title | String | 是 | 广告文案 |
| dimension_length | int | 是 | 广告文案文本长度 |
description 对象:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| description | String | 是 | 广告描述 |
| dimension_length | int | 是 | 广告描述文本长度 |
corporate_name 对象:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| name | String | 是 | 商标名称 |
| dimension_length | int | 是 | 商标名称文本长度 |
corporate_img、image、image2、image3 对象:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| image_url | string | 是 | 图片URL |
| type | int | 是 | 图片类型(1.png / 2.jpg / 3.gif) |
| size_dimension | string | 是 | 图片规格(宽*高px) |
| size_kb | int | 是 | 图片大小 |
video 对象:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| video_url | string | 是 | 视频URL |
| type | int | 是 | 图片类型(4.mp4 / 5.swf / 6.flv) |
| size_dimension | string | 是 | 视频规格(宽*高px) |
| size_kb | int | 是 | 视频大小 |
| duration | int | 是 | 视频时长 |
请求示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | {
"advertiserId": 1,
"clickTrackingUrl": "http://www.marketin.cn",
"clickUrl": "http://www.marketin.cn",
"cooperatorCreativeId": "178",
"creativeElement": {
"image": {"type": 2, "size_kb": 33, "image_url": "http://www.test.com", "size_dimension": " 640*100 "},
"title": {"title": "title1", "dimension_length": 123},
"video": {"type": 4, "size_kb": 55, "duration": 333, "video_url": " http://www.test.com ", "size_dimension": " 640*100 "},
"image2": {"type": 2, "size_kb": 55, "image_url": " http://www.test.com ", "size_dimension": " 640*100 "},
"image3": {"type": 2, "size_kb": 77, "image_url": " http://www.test.com ", "size_dimension": " 640*100 "},
"description": {"description": "description1", "dimension_length": 10},
"corporate_img": {"type": 3, "size_kb": 3, "image_url": " http://www.test.com ", "size_dimension": "640*100"},
"corporate_name": {"name": "aaa2", "dimension_length": 333}
},
"creativeName": "JPG300*250",
"creativeType": 5,
"impTrackingUrls": [
"http://www.marketin.cn"
],
"siteUrl": "http://www.marketin.cn"
}
|
返回字段:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| creativeId | Long | 是 | SSP 平台上创意ID;例如:10123 |
返回示例:
1 2 3 4 5 6 7 | {
"code": 0,
"message": "成功",
"data": {
"creativeId": 10010
}
}
|
创意查询¶
- 请求URL:
/api/creative/checklist- 请求方式:
GET
请求字段:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| creativeIds | String | 是 | SSP 平台上创意ID,多个创意ID 用逗号“,”分割。最多支持 200个 |
返回字段:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| creatives | Array Object | 否 | 创意对象 |
creatives 对象:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| creativeId | int64 | 否 | 创意ID |
| status | int | 否 | 状态 1:审核通过/30:审核中/31:未审核/40:审核拒绝 |
| preAdServing | int64 | 否 | 审核前可投放状态 0:审核前不可投/1:审核前可投 |
| rejectReason | string | 否 | 审核拒绝原因, 审核拒绝时有效 |
返回示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 | {
"code": 0,
"message": "成功",
"data": {
"creatives": [
{
"creativeId": 319,
"status": 1,
"preAdServing ": 1
}
]
}
}
|
合作方报表API¶
合作方报表API可以实现查询合作平台花费小时报和日报
创意查询¶
- 请求URL:
/api/report/cooperator- 请求方式:
POST
请求字段:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| startdate | String | 是 | 查询的开始时间 |
| enddate | String | 是 | 查询的结束时间 |
返回字段:
| 参数名称 | 类型 | 必须 | 说明 |
|---|---|---|---|
| key | String | 是 | 时间 |
| req_number | Int | 是 | 请求数 |
| imps | Int | 是 | 展示数 |
| clicks | Int | 是 | 点击数 |
| fill_rate | String | 是 | 填充率 |
| ctr | String | 是 | 点击率 |
| cpm | String | 是 | 千次曝光成本 |
| cpc | String | 是 | 每次点击成本 |
| cost | String | 是 | 花费 |
返回示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | {
"code": 0,
"data": {
"20171113": {
"key": "20171113",
"req_number": 0,
"imps": 0,
"clicks": 0,
"fill_rate": "0.00",
"ctr": "0.00",
"cpm": "0.00",
"cpc": "0.00",
"cost": "0.00"
},
"20171114": {
"key": "20171114",
"req_number": 0,
"imps": 0,
"clicks": 0,
"fill_rate": "0.00",
"ctr": "0.00",
"cpm": "0.00",
"cpc": "0.00",
"cost": "0.00"
}
},
"message": "成功"
}
|
请求示例¶
请求示例提供php、python两种请求平台api示例
沙盒地址:http://sandbox.ssp.adxing.com
广告主新建示例¶
php请求示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <?php
$curl = new HttpCurl();
$app_id = "c921dabf8f05e1024e8765fb6d712345"; //your app_id
$user_id = "12345"; //your user_id
$app_key = "6BF6A168-65A0-66D8-7704-970AE9D12345"; //your app_key
$timestamp = time();
$signature = sha1($app_id.$app_key.$timestamp);
$token = base64_encode($app_id.",".$user_id.",".$timestamp.",".$signature);
$headers = ["Authorization"=>"Bearer ".$token];
$postFields = [
"advertiserName" => "广告主名称",//dsp 系统的广告主名称
"industryId" => 106003, //行业ID
"siteUrl" => "https://www.baidu.com/", //网站URL http://或https://开头
"certificationFile" => "https://mmptrsbox.limei.com/cdn/c-33e41c79-2b9e-494c-9f03-31ed5a5b758b.jpg"//营业执照文件
];
$postFields = json_encode($postFields);
$url = "http://xxx.xxxx.xxxx/api/advertiser/create";//请求地址
$res = $curl::curl($url,$httpMethod="POST",$postFields,$headers);
if(json_decode($res,true)["code"] == 0) {
echo "成功";
}else{
echo "失败";
}
?>
|
python请求示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # -*- coding: utf-8 -*-
import requests
import json
import base64
import hashlib
import time
app_id = "c921dabf8f05e1024e8765fb6d712345"; #your app_id
user_id = "12345"; #your user_id
app_key = "6BF6A168-65A0-66D8-7704-970AE9D12345"; #your app_key
time1 = time.time()
timestamp = str(int(time1))
signature = hashlib.sha1(app_id + app_key + timestamp).hexdigest()
token = base64.b64encode(app_id + "," + user_id + "," + timestamp + "," + signature)
url = 'http://xxx.xxxx.xxxx/api/advertiser/create' #请求地址
data = {"advertiserName": "广告主名称", #dsp 系统的广告主名称
"industryId": 110006, #行业ID
"siteUrl": "http://www.baidu.com", #网站URL http://或https://开头
"certificationFile": "https://mmptrsbox.limei.com/cdn/c-33e41c79-2b9e-494c-9f03-31ed5a5b758b.jpg" #营业执照文件
}
bearer_token = "Bearer " + token
headers = {
"Authorization": bearer_token
}
r = requests.post(url, headers=headers, data=json.dumps(data))
a = r.content
print(a)
|
广告主编辑示例¶
php请求示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <?php
$curl = new HttpCurl();
$app_id = "c921dabf8f05e1024e8765fb6d712345"; //your app_id
$user_id = "12345"; //your user_id
$app_key = "6BF6A168-65A0-66D8-7704-970AE9D12345"; //your app_key
$timestamp = time();
$signature = sha1($app_id.$app_key.$timestamp);
$token = base64_encode($app_id.",".$user_id.",".$timestamp.",".$signature);
$headers = ["Authorization"=>"Bearer ".$token];
$postFields = [
"advertiserId" => 10041, //SSP 平台上广告主ID
"advertiserName" => "修改名称", //dsp 系统的广告主名称
"industryId" => 106003, //行业ID
"siteUrl" => "https://www.google.com/", //网站URL http://或https://开头
"certificationFile" => "https://mmptrsbox.limei.com/cdn/c-33e41c79-2b9e-494c-9f03-31ed5a5b758b.jpg"//营业执照文件
];
$postFields = json_encode($postFields);
$url = "http://xxx.xxxx.xxxx/api/advertiser/update"; //请求地址
$res = $curl::curl($url,$httpMethod="POST",$postFields,$headers);
if(json_decode($res,true)["code"] == 0) {
echo "成功";
}else{
echo "失败";
}
?>
|
python请求示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # -*- coding: utf-8 -*-
import requests
import json
import base64
import hashlib
import time
app_id = "c921dabf8f05e1024e8765fb6d712345"; #your app_id
user_id = "12345"; #your user_id
app_key = "6BF6A168-65A0-66D8-7704-970AE9D12345"; #your app_key
time1 = time.time()
timestamp = str(int(time1))
signature = hashlib.sha1(app_id + app_key + timestamp).hexdigest()
token = base64.b64encode(app_id + "," + user_id + "," + timestamp + "," + signature)
url = 'http://xxx.xxxx.xxxx/api/advertiser/update' #请求地址
data = {"advertiserId": 10038, #SSP 平台上广告主ID
"advertiserName": "修改名称", #dsp 系统的广告主名称
"industryId": 110006, #行业ID
"siteUrl": "http://www.baidu.com", #网站URL http://或https://开头
"certificationFile": "https://mmptrsbox.limei.com/cdn/c-33e41c79-2b9e-494c-9f03-31ed5a5b758b.jpg" #营业执照文件
}
bearer_token = "Bearer " + token
headers = {
"Authorization": bearer_token
}
r = requests.post(url, headers=headers, data=json.dumps(data))
a = r.content
print(a)
|
广告主查询示例¶
php请求示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <?php
$curl = new HttpCurl();
$app_id = "c921dabf8f05e1024e8765fb6d712345"; //your app_id
$user_id = "12345"; //your user_id
$app_key = "6BF6A168-65A0-66D8-7704-970AE9D12345"; //your app_key
$timestamp = time();
$signature = sha1($app_id.$app_key.$timestamp);
$token = base64_encode($app_id.",".$user_id.",".$timestamp.",".$signature);
$headers = ["Authorization"=>"Bearer ".$token];
//广告主查询有两种方式,第一种只传ID,第二种传ID和需要的字段
//第一种
$url = "http://xxx.xxxx.xxxx/api/advertiser/AdvertiserId"; //请求地址,AdvertiserId:要查询的广告主ID,返回广告主全部信息
//第二种
$fields = "advertiserId,certificationFile,advertiserName";//需要查询的字段,查询只返回这些字段信息
$url = "http://xxx.xxxx.xxxx/api/advertiser/AdvertiserId".'/'.$fields; //请求地址,AdvertiserId:要查询的广告主ID
$res = $curl::curl($url,$httpMethod = "GET",$postFields = null,$headers);
if(json_decode($res,true)["code"] == 0) {
echo "成功";
}else{
echo "失败";
}
?>
|
python请求示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # -*- coding: utf-8 -*-
import requests
import json
import base64
import hashlib
import time
app_id = "c921dabf8f05e1024e8765fb6d712345"; #your app_id
user_id = "12345"; #your user_id
app_key = "6BF6A168-65A0-66D8-7704-970AE9D12345"; #your app_key
time1 = time.time()
timestamp = str(int(time1))
signature = hashlib.sha1(app_id + app_key + timestamp).hexdigest()
token = base64.b64encode(app_id + "," + user_id + "," + timestamp + "," + signature)
#广告主查询有两种方式,第一种只传ID,第二种传ID和需要的字段
#第一种
url = "http://xxx.xxxx.xxxx/api/advertiser/AdvertiserId"; #请求地址,AdvertiserId:要查询的广告主ID,返回广告主全部信息
#第二种
fields = "advertiserId,certificationFile,advertiserName"; #需要查询的字段,查询只返回这些字段信息
url = "http://xxx.xxxx.xxxx/api/advertiser/AdvertiserId" + '/' + fields; #请求地址,AdvertiserId:要查询的广告主ID
bearer_token = "Bearer " + token
headers = {
"Authorization": bearer_token
}
r = requests.get(url, headers=headers)
a = r.content
print(a)
|
广告主列表查询示例¶
php请求示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <?php
$curl = new HttpCurl();
$app_id = "c921dabf8f05e1024e8765fb6d712345"; //your app_id
$user_id = "12345"; //your user_id
$app_key = "6BF6A168-65A0-66D8-7704-970AE9D12345"; //your app_key
$timestamp = time();
$signature = sha1($app_id.$app_key.$timestamp);
$token = base64_encode($app_id.",".$user_id.",".$timestamp.",".$signature);
$headers = ["Authorization"=>"Bearer ".$token];
$url = "http://xxx.xxxx.xxxx/api/advertiser?page=1&pageSize=10&fields=advertiserId,status"; //请求地址
$res = $curl::curl($url,$httpMethod = "GET",$postFields = null,$headers);
if(json_decode($res,true)["code"] == 0) {
echo "成功";
}else{
echo "失败";
}
?>
|
python请求示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # -*- coding: utf-8 -*-
import requests
import json
import base64
import hashlib
import time
app_id = "c921dabf8f05e1024e8765fb6d712345"; #your app_id
user_id = "12345"; #your user_id
app_key = "6BF6A168-65A0-66D8-7704-970AE9D12345"; #your app_key
time1 = time.time()
timestamp = str(int(time1))
signature = hashlib.sha1(app_id + app_key + timestamp).hexdigest()
token = base64.b64encode(app_id + "," + user_id + "," + timestamp + "," + signature)
url = "http://xxx.xxxx.xxxx/api/advertiser?page=1&pageSize=10&fields=advertiserId,status"; #请求地址
bearer_token = "Bearer " + token
headers = {
"Authorization": bearer_token
}
r = requests.get(url, headers=headers)
a = r.content
print(a)
|
创意新建示例¶
php请求示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | <?php
$curl = new HttpCurl();
$app_id = "c921dabf8f05e1024e8765fb6d712345"; //your app_id
$user_id = "12345"; //your user_id
$app_key = "6BF6A168-65A0-66D8-7704-970AE9D12345"; //your app_key
$timestamp = time();
$signature = sha1($app_id.$app_key.$timestamp);
$token = base64_encode($app_id.",".$user_id.",".$timestamp.",".$signature);
$headers = ["Authorization"=>"Bearer ".$token];
$postFields = [
"advertiserId" => "10037", //SSP 平台上广告主ID
"creativeName" => "创意名称", //创意名称
"cooperatorCreativeId" => "10000",//合作平台创意ID
"creativeType" => 1, //创意类型
"creativeElement" => [ //创意元素;广告位广告类型对应具体广告元素
"image" => [
"image_url" => "https://mmptrsbox.limei.com/cdn/c-33e41c79-2b9e-494c-9f03-31ed5a5b758b.jpg", //图片URL
"type" => 2, //图片类型(1.png / 2.jpg / 3.gif)
"size_dimension" => "330*400", //图片规格(宽*高px)
"size_kb" => 9 //图片大小
]
],
"clickTrackingUrl" => "https://imgsa.baidu.com/forum/w%3D580%3B/sign=731c14c36b59252da3171d0c04a0013b/4a36acaf2edda3ccd63c4ef90ae93901203f920b.jpg" //点击地址(监控)注:如果site_url、click_url同时存在, 点击响应地址为click_url
];
$postFields = json_encode($postFields);
$url = "http://xxx.xxxx.xxxx/api/creative/inventory/create"; //请求地址
$res = $curl::curl($url,$httpMethod="POST",$postFields,$headers);
if(json_decode($res,true)["code"] == 0) {
echo "成功";
}else{
echo "失败";
}
?>
|
python请求示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | # -*- coding: utf-8 -*-
import requests
import json
import base64
import hashlib
import time
app_id = "c921dabf8f05e1024e8765fb6d712345"; #your app_id
user_id = "12345"; #your user_id
app_key = "6BF6A168-65A0-66D8-7704-970AE9D12345"; #your app_key
time1 = time.time()
timestamp = str(int(time1))
signature = hashlib.sha1(app_id + app_key + timestamp).hexdigest()
token = base64.b64encode(app_id + "," + user_id + "," + timestamp + "," + signature)
url = 'http://xxx.xxxx.xxxx/api/creative/inventory/create' #请求地址
data = {"advertiserId": "10038", #SSP 平台上广告主ID
"clickTrackingUrl": "http://www.baidu.com", #点击地址(监控)注:如果site_url、click_url同时存在, 点击响应地址为click_url
"cooperatorCreativeId": "10000", #合作平台创意ID
"creativeName": "创意名称", #创意名称
"creativeType": 1, #创意类型
"creativeElement": #创意元素;广告位广告类型对应具体广告元素
{"image":
{"type": 1, #图片类型(1.png / 2.jpg / 3.gif)
"size_dimension": "180*240", #图片规格(宽*高px)
"size_kb": 10, #图片大小
"image_url": "https://mmptrsbox.limei.com/cdn/c-33e41c79-2b9e-494c-9f03-31ed5a5b758b.jpg" #图片URL
}
}
}
bearer_token = "Bearer " + token
headers = {
"Authorization": bearer_token
}
r = requests.post(url, headers=headers, data=json.dumps(data))
a = r.content
print(a)
|
创意查询示例¶
php请求示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | <?php
$curl = new HttpCurl();
$app_id = "c921dabf8f05e1024e8765fb6d712345"; //your app_id
$user_id = "12345"; //your user_id
$app_key = "6BF6A168-65A0-66D8-7704-970AE9D12345"; //your app_key
$timestamp = time();
$signature = sha1($app_id.$app_key.$timestamp);
$token = base64_encode($app_id.",".$user_id.",".$timestamp.",".$signature);
$headers = ["Authorization"=>"Bearer ".$token];
$url = "http://xxx.xxxx.xxxx/api/creative/checklist/CreativeId"; //请求地址,CreativeId:SSP 平台上创意ID,多个创意ID 用逗号“,”分割。例如10012,10013
$res = $curl::curl($url,$httpMethod = "GET",$postFields = null,$headers);
if(json_decode($res,true)["code"] == 0) {
echo "成功";
}else{
echo "失败";
}
?>
|
python请求示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # -*- coding: utf-8 -*-
import requests
import json
import base64
import hashlib
import time
app_id = "c921dabf8f05e1024e8765fb6d712345"; #your app_id
user_id = "12345"; #your user_id
app_key = "6BF6A168-65A0-66D8-7704-970AE9D12345"; #your app_key
time1 = time.time()
timestamp = str(int(time1))
signature = hashlib.sha1(app_id + app_key + timestamp).hexdigest()
token = base64.b64encode(app_id + "," + user_id + "," + timestamp + "," + signature)
url = 'http://xxx.xxxx.xxxx/api/creative/checklist/CreativeId' #请求地址,CreativeId:SSP 平台上创意ID,多个创意ID 用逗号“,”分割。例如10012,10013
bearer_token = "Bearer " + token
headers = {
"Authorization": bearer_token
}
r = requests.get(url, headers=headers)
a = r.content
print(a)
|
合作方报表查询示例¶
php请求示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <?php
$curl = new HttpCurl();
$app_id = "c921dabf8f05e1024e8765fb6d712345"; //your app_id
$user_id = "12345"; //your user_id
$app_key = "6BF6A168-65A0-66D8-7704-970AE9D12345"; //your app_key
$timestamp = time();
$signature = sha1($app_id.$app_key.$timestamp);
$token = base64_encode($app_id.",".$user_id.",".$timestamp.",".$signature);
$headers = ["Authorization"=>"Bearer ".$token];
$postFields = [
"startdate"=>"2017-11-13", //开始时间
"enddate"=>"2017-11-13" //结束时间
];
$postFields = json_encode($postFields);
$url = "http://xxx.xxxx.xxxx/api/report/cooperator"; //请求地址
$res = $curl::curl($url,$httpMethod="POST",$postFields,$headers);
if(json_decode($res,true)["code"] == 0) {
echo "成功";
}else{
echo "失败";
}
?>
|
python请求示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # -*- coding: utf-8 -*-
import requests
import json
import base64
import hashlib
import time
app_id = "c921dabf8f05e1024e8765fb6d712345"; #your app_id
user_id = "12345"; #your user_id
app_key = "6BF6A168-65A0-66D8-7704-970AE9D12345"; #your app_key
time1 = time.time()
timestamp = str(int(time1))
signature = hashlib.sha1(app_id + app_key + timestamp).hexdigest()
token = base64.b64encode(app_id + "," + user_id + "," + timestamp + "," + signature)
url = 'http://xxx.xxxx.xxxx/api/report/cooperator'
data = {
"startdate": "2017-11-12", #开始时间
"enddate": "2017-11-21" #结束时间
}
bearer_token = "Bearer " + token
headers = {
"Authorization": bearer_token
}
r = requests.post(url, headers=headers, data=json.dumps(data))
a = r.content
print(a)
|