Marketing API
大约 22 分钟
Marketing API
更新日志
更新日期 | 更新说明 |
---|---|
2024年11月1日 | 文档初建 |
1.权限认证
API 通过参数签名的方式进行权限控制,签名所需的 accessKey 和 securityKey, 请到变现平台-账号管理- 密钥信息中获取。
2.签名生成
使用 accessKey、timeStamp、nonce和securityKey 作md5,生成本次请求的sign
2.1 签名代码示例
public static void main(String[] args) {
String accessKey = "cqAkc7nE1X2etiQR";
String secureKey = "5361dec44de774d9adaf46a98ce9a910427885bd";
// 接口url
String url = "https://lemon.gameley.com/flowapi/adn/mediaDataReport/reportApi";
String timeStamp = System.currentTimeMillis() + "";
Integer random = (int)(Math.random()*10);
// 签名
TreeMap<String, Object> treeMap = new TreeMap<>();
treeMap.put("accessKey",accessKey);
treeMap.put("timeStamp",timeStamp);
treeMap.put("nonce",random.toString());
String sign = getSign(treeMap, secureKey);
System.out.println(sign);
//请求体参数
JSONObject data = new JSONObject();
data.put("strTime","2024-02-26");
String body = HttpUtil.createPost(url)
.header("accessKey",accessKey)
.header("sign",sign)
.header("timeStamp",timeStamp)
.header("nonce",random.toString())
.body(data.toString())
.execute().body();
System.out.println(JSON.toJSON(body));
}
/**
* 获取密钥
* @param request 签名的参数
* @param secure_key secureKey
* @return 参数拼接的字符串
*/
public static String getSign(Map<String, Object> request, String secure_key) {
Set<Map.Entry<String, Object>> entries = request.entrySet();
String str = "";
int i = 0;
for (Map.Entry<String, Object> e : entries) {
i++;
str += e.getKey();
str += "=";
str += e.getValue().toString();
if (i != request.size()) {
str += "&";
}
}
str += secure_key;
return getMD5Str(str);
}
/**
* Md5加密
* @param str 参数拼接的字符串
* @return sign签名结果
*/
public static String getMD5Str(String str) {
byte[] digest = null;
try {
MessageDigest md5 = MessageDigest.getInstance("md5");
digest = md5.digest(str.getBytes("utf-8"));
} catch (Exception e) {
e.printStackTrace();
}
StringBuilder md5StrBuilder = new StringBuilder();
for (byte tmp : Objects.requireNonNull(digest)) {
md5StrBuilder.append(String.format("%02x", tmp & 0xff));
}
return md5StrBuilder.toString();
}
2.2 响应码
状态码 | 描述 | 备注 |
---|---|---|
2000 | 成功 | 当 API 请求被正确处理,且能按设计获取结果时,返回该状态码; |
2001 | 服务器异常 | |
2003 | 权限不足 | |
300 | 签名错误 | 签名算法有误,或securityKey失效 |
301 | 时间戳无效或请求已过期 | |
302 | accessKey不存在 | |
303 | 请求头必传参数不能为空 | |
3001 | 参数校验异常 | 参数异常,message中会有详情 |
3002 | 相关设置只能设置一次 | |
3003 | 设置不可修改 |
3.应用模块
3.1 新增应用
请求地址:https://lemon.gameley.com/flowapi/adn/app/add
请求方法:POST
Content-Type:application/json
请求参数:
0测试 1正式 | ||||
非必填 | ||||
返回字段:
响应字段 | 类型 | 描述 |
---|---|---|
flag | boolean | 返回结果 |
code | int | 返回结果状态码 |
message | string | 描述信息 |
data | 数据对象 |
应答示例:
{
"flag": true,
"code": 2000,
"message": "请求成功",
"data": {
"app_id":600001
}
}
3.2 编辑应用
请求地址:https://lemon.gameley.com/flowapi/adn/app/update
请求方法:POST
Content-Type:application/json
请求参数:
int | ||||
非必填 | ||||
返回成功示例
{
"flag": true,
"code": 2000,
"message": "请求成功",
"data": null
}
3.3 查询应用列表
请求地址:https://lemon.gameley.com/flowapi/adn/app/list
请求方法:POST
Content-Type:application/json
请求参数
string | ||||
响应参数
int | ||
合作状态,0代表暂停,1代表开启 | ||
应用状态 0测试 1运行中 2审核中 3审核拒绝 4异常停止 5停止 |
应答示例:
{
"flag": true,
"code": 2000,
"message": "请求成功",
"data": {
"total": 5,
"page": 1,
"list": [
{
"app_id": 600348,
"app_type": 1,
"os": 2,
"app_name": "测试新建API",
"app_store_id": 600348,
"detail_url": null,
"package_name": "com.example.pullApi",
"sha1": "88e7c7c7c7c7c7c7c7c7c7c7c7c7c7c8",
"industry_id": 38,
"app_status": 1,
"status": 1
}
],
"page_size": 20
}
}
4.代码位模块
4.1 新建代码位
请求地址:https://lemon.gameley.com/flowapi/adn/position/add
请求方法:POST
Content-Type:application/json
请求字段:
string | ||||
string | ||||
int32 | 1 : 开屏广告, 3: 原生广告, 4 : Banner, 5 : 插屏广告, 6: 激励视频 | |||
string | 代码位可接受素材类型 原生或插屏模板渲染 单选 1-仅图片 2-仅视频 3-图片+视频 原生自渲染 可多选 4-横版视频 5-竖版视频 6-横版图片 7-竖版图片 8-多图 | |||
int32 | 0:模板渲染 1:自渲染 | |||
string | 1:左图右文 2:上图下文 3: 横版纯图片 4:三小图双文 5:左文右图 6:上文下图 | |||
int32 | 1:竖屏 2:横屏 | |||
1:全屏 2:半屏 | ||||
0:目标价 1:实时竞价 | 必填 | |||
0:设置期望 CPM 1:自动优化 | ||||
应答示例:
{
"flag": true,
"code": 2000,
"message": "请求成功",
"data": {
"app_id": 600348,
"ad_position_id": 130000184,
"ad_position_name": "测试API创建代码位 20241017190122",
"ad_type": 3,
"ad_source": "6,7",
"render_type": 1,
"ad_template": null,
"screen_orient": null,
"ad_interstitial_area": null,
"bidding_type": 0,
"ecpm_setting": 0,
"ecpm_price": 3000,
"bid_floor_price": null
}
}
4.2 编辑代码位
请求地址:https://lemon.gameley.com/flowapi/adn/position/update
请求方法:POST
Content-Type:application/json
请求字段:
string | ||||
string | ||||
string | ||||
int32 | 1 : 开屏广告, 3: 原生广告, 4 : Banner, 5 : 插屏广告, 6: 激励视频 | |||
string | 代码位可接受素材类型 原生或插屏模板渲染 单选 1-仅图片 2-仅视频 3-图片+视频 原生自渲染 可多选 4-横版视频 5-竖版视频 6-横版图片 7-竖版图片 8-多图 | |||
string | 1:左图右文 2:左文右图 3:上图下文 4:上文下图 5:横板纯图片 6:三小图双文 | 多个使用,隔开 | ||
int32 | 1:竖屏 2:横屏 | |||
1:全屏 2:半屏 | ||||
0:设置期望 CPM 1:自动优化 | ||||
应答示例:
{
"flag": true,
"code": 2000,
"message": "请求成功",
"data": {
"app_id": 600348,
"ad_position_id": 130000184,
"ad_position_name": "测试API创建代码位 20241017190252",
"ad_type": 3,
"ad_source": "6,7",
"render_type": 1,
"ad_template": null,
"screen_orient": null,
"ad_interstitial_area": null,
"bidding_type": 0,
"ecpm_setting": 0,
"ecpm_price": 300.0,
"bid_floor_price": null
}
}
4.3 查询应用下代码位列表
请求地址:https://lemon.gameley.com/flowapi/adn/position/list
请求方法:POST
Content-Type:application/json
请求字段:
string | ||||
string | ||||
string | 代码位 ID | |||
应答示例:
{
"flag": true,
"code": 2000,
"message": "请求成功",
"data": {
"total": 1,
"page": 1,
"list": [
{
"app_id": 600348, // 应用id
"ad_position_id": 130000184, // 代码位id
"ad_position_name": "测试API创建代码位", // 代码位名称
"ad_type": 3, // 广告类型
/**
* 广告素材类型 ,隔开
* 代码位可接受素材类型
* 1-仅图片,2-仅视频,3-图片+视频
*
* 自渲染时候
* 4横版视频 5竖版视频 6横版图片 7竖版图片 8多图
*/
"ad_source": "6,7",
"render_type": 1, // 渲染方式:0模板渲染,1代表开发者自渲染
"ad_template": null, //原生广告模板样式1:左图右文 2:上图下文 3: 横版纯图片 4:三小图双文
5:左文右图 6:上文下图
"screen_orient": null, // 激励视频 屏幕方向 1竖屏 2横屏
"ad_interstitial_area": null, // 广告铺开大小 1是全屏,2是半屏
"bidding_type": 0, // 竞价类型 0 目标价 1实时竞价
"ecpm_setting": 0, // 期望 cpm 状态 0设置cpm 1自动优化
"ecpm_price": 300, // 期望 eCPM 价格 0-3000 的两位小数
"bid_floor_price": null, //竞价底价
"pos_status": 1, // 广告位状态 测试-0 运行中-1 异常停止-4 停止-5
"status":1 //广告位合作状态 0停止 1正常
}
],
"page_size": 10
}
}
附录-应用商店
应用商店 | 应用商店 | ||
---|---|---|---|
附录-行业
行业 | industry_id | 行业 | industry_id |
---|---|---|---|