跳到主要内容

其他接口

1、邮箱收集

1.1、打开邮箱收集页面(研发不需要提供收集界面)

String param = DHPluginParam.Builder()
.put("plugin_type", "tools") //固定字段
.put("unionsdk_type", "platform") //固定字段
.put("event_type", "sendemail") //固定字段
.toString();

DHSDKHelper.getInstance().exec(this, param, new IDHSDKCallback() {

@Override
public void onDHSDKResult(int requestCode, int resultCode, String resultData) {
Log.d(arg2);
}
});

回调结果:

requestCode 请求码 :DHSDKConst.REQ_EXEC (所有扩展接口的请求码统一 , 可以使用resultData中的event_type来区分请求)
resultCode 结果码 : resultCode == DHSDKConst.RET_OK:成功
resultCode ==DHSDKConst.RET_FAIL:失败
resultData : {"event_type":"sendemail","data":"设置成功"}

1.2、上报邮箱信息(研发提供收集界面,前提已收集到用户邮箱)

String jsonstring = DHPluginParam.Builder()             
.put("nickname", "昵称") // 昵称
.put("email", "玩家真实的邮箱") // 邮箱信息
.toString();

String param = DHPluginParam.Builder()
.put("plugin_type", "tools") //固定字段
.put("unionsdk_type", "platform") //固定字段
.put("event_type", "sendemail") //固定字段
.put("jsonstring", jsonstring)
.toString();

DHSDKHelper.getInstance().exec(this, param, new IDHSDKCallback() {
@Override
public void onDHSDKResult(int requestCode, int resultCode, String resultData) {
Log.d(arg2);
}
});

回调结果:

requestCode 请求码 :DHSDKConst.REQ_EXEC (所有扩展接口的请求码统一 , 可以使用resultData中的event_type来区分请求)
resultCode 结果码 : resultCode == DHSDKConst.RET_OK:成功
resultCode ==DHSDKConst.RET_FAIL:失败
resultData : {"event_type":"sendemail","data":"设置成功"}

2、关联手机号

警告

账号关联手机号码接口仅限中国大陆

2.1、查询绑定

新版接口:

import com.dh.DHSDKConst;
import com.dh.DHSDKHelper;
import com.dh.callback.IDHSDKCallback;
import com.dh.framework.utils.DHPluginParam;

import org.json.JSONObject;

String param = DHPluginParam.Builder()
.put("plugin_type", "tools")
.put("unionsdk_type", "platform")
.put("event_key", "query")
.put("event_type", "bindUserPhone")
.put("jsonstring", new JSONObject()
// .put("connect", "bind") //(可选)绑定多端互通角色:默认不传该字段,只收集手机号
.toString())
.toString();

/**
* @param activity 上下文
* @param sdkCallback 回调对象
*/
DHSDKHelper.getInstance().exec(activity, param, new IDHSDKCallback() {
@Override
public void onDHSDKResult(int requestCode, int resultCode, String resultData) {
switch (requestCode) {
case 101:
// 查询结果
if (resultCode == DHSDKConst.RET_OK) {
// JSONObject result = new JSONObject(resultData);
// String state = result.getString("success"); // 1=已绑定,2=未绑定,其它失败
} else if (resultCode == DHSDKConst.RET_FAIL) {
// 查询失败
}
break;
default:
// 其他结果
break;
}
}
});

请求成功时,示例如下:

{"success":"2", "info":"没有绑定手机号码"}
{"success":"1", "info":"已绑定手机号码", "bindPhone":"131****0130"}
参数类型说明
infoString描述结果
successString1=已绑定,2=未绑定,其它失败
bindPhoneString绑定的手机号,131****0130,已绑定时,有此字段

2.2、游戏自制界面

2.2.1、发送短信(需自制界面)

新版接口:

import com.dh.DHSDKConst;
import com.dh.DHSDKHelper;
import com.dh.callback.IDHSDKCallback;
import com.dh.framework.utils.DHPluginParam;

import org.json.JSONObject;

String param = DHPluginParam.Builder()
.put("plugin_type", "tools")
.put("unionsdk_type", "platform")
.put("event_key", "send")
.put("event_type", "bindUserPhone")
.put("jsonstring", new JSONObject()
.put("mobile", "手机号")
// .put("connect", "bind") //(可选)绑定多端互通角色:默认不传该字段,只收集手机号
.toString())
.toString();

/**
* @param activity 上下文
* @param sdkCallback 回调对象
*/
DHSDKHelper.getInstance().exec(activity, param, new IDHSDKCallback() {
@Override
public void onDHSDKResult(int requestCode, int resultCode, String resultData) {
switch (requestCode) {
case 102:
// 发送结果
if (resultCode == DHSDKConst.RET_OK) {
// JSONObject result = new JSONObject(resultData);
// String state = result.getString("success"); // 1=发送成功,2=发送失败,其它失败
} else if (resultCode == DHSDKConst.RET_FAIL) {
// 发送失败
}
break;
default:
// 其他结果
break;
}
}
});

请求成功时,示例

{"success":"1", "info":"发送成功"}
{"success":"2", "info":"发送失败"}
参数类型说明
infoString描述信息
successString1=发送成功,2=发送失败,其它失败

2.2.2、绑定手机号码(需自制界面)

新版接口:

import com.dh.DHSDKConst;
import com.dh.DHSDKHelper;
import com.dh.callback.IDHSDKCallback;
import com.dh.framework.utils.DHPluginParam;

import org.json.JSONObject;

String param = DHPluginParam.Builder()
.put("plugin_type", "tools")
.put("unionsdk_type", "platform")
.put("event_key", "bind")
.put("event_type", "bindUserPhone")
.put("jsonstring", new JSONObject()
.put("code", "验证码")
.put("mobile", "手机号")
// .put("connect", "bind") //(可选)绑定多端互通角色:默认不传该字段,只收集手机号
.toString())
.toString();

/**
* @param activity 上下文
* @param sdkCallback 回调对象
*/
DHSDKHelper.getInstance().exec(activity, param, new IDHSDKCallback() {
@Override
public void onDHSDKResult(int requestCode, int resultCode, String resultData) {
switch (requestCode) {
case 103:
// 绑定结果
if (resultCode == DHSDKConst.RET_OK) {
// JSONObject result = new JSONObject(resultData);
// String state = result.getString("success"); // 1=绑定成功,2=绑定失败,其它失败
} else if (resultCode == DHSDKConst.RET_FAIL) {
// 绑定失败
}
break;
default:
// 其他结果
break;
}
}
});

请求成功时,示例如下

{"success":"2", "info":"绑定失败"}
{"success":"1", "info":"绑定成功", "bindPhone":"131****0130"}
参数类型说明
infoString描述信息
successString1=绑定成功,2=绑定失败,其它失败
bindPhoneString绑定的手机号,例如:131****0130
{"success":"2", "info":"绑定失败"}
{"success":"1", "info":"绑定成功", "bindPhone":"131****0130", "bindChange":"0","bindAccount":......}
{"success":"1", "info":"绑定成功", "bindPhone":"131****0130", "bindChange":"1","bindAccount":......}

绑定多端互通角色时有额外字段,游戏可以根据bindChange判断是否绑定后是新账号。

参数类型说明
bindChangeString绑定后是否新号,例如:1,新账号;0,未变动
bindAccountObject绑定后账号信息,详细数据结构请参考登录接口

2.3、使用SDK统一界面

注意

委托使用SDK统一界面,仅包含输入手机号发送验证码、输入验证码绑定手机号,不含查询

2.3.1、委托发送、绑定(使用统一界面)

新版接口:

import com.dh.DHSDKConst;
import com.dh.DHSDKHelper;
import com.dh.callback.IDHSDKCallback;
import com.dh.framework.utils.DHPluginParam;

import org.json.JSONObject;

String param = DHPluginParam.Builder()
.put("plugin_type", "tools")
.put("unionsdk_type", "platform")
.put("event_key", "delegate")
.put("event_type", "bindUserPhone")
.put("jsonstring", new JSONObject()
// .put("connect", "bind") //(可选)绑定多端互通角色:默认不传该字段,只收集手机号
.toString())
.toString();

/**
* @param activity 上下文
* @param sdkCallback 回调对象
*/
DHSDKHelper.getInstance().exec(activity, param, new IDHSDKCallback() {
@Override
public void onDHSDKResult(int requestCode, int resultCode, String resultData) {
switch (requestCode) {
case 103:
// 绑定结果
if (resultCode == DHSDKConst.RET_OK) {
// 绑定成功
// JSONObject result = new JSONObject(resultData);
} else if (resultCode == DHSDKConst.RET_FAIL) {
// 绑定失败
}
break;
default:
// 其他结果
break;
}
}
});

请求成功时,示例如下

{"success":"2", "info":"绑定失败"}
{"success":"1", "info":"绑定成功", "bindPhone":"131****0130"}
参数类型说明
infoString描述信息
successString1=绑定成功,2=绑定失败,其它失败
bindPhoneString绑定的手机号,例如:131****0130

绑定多端互通角色时有额外字段,请参考绑定手机号码接口。

参数类型说明
bindChangeString绑定后是否新号,例如:1,新账号;0,未变动
bindAccountObject绑定后账号信息,详细数据结构请参考登录接口

3、谷歌本地货币查询(选接)

注意

本地货币查询接口,海外选接,但谷歌包必接!

接入时请特别注意,此接口返回的货币和价格仅用于游戏界面展示。此外,调用支付接口时传入price为道具原价(并非是productPrice),currency固定是USD(并非是productCurrency

ResultData:返回的JSON是一个包含多个对象的JSON数组。游戏方需要根据productId从该数组中搜索对应的JSON对象。如果找到匹配的productId,则展示对应的价格productPrice如果没有匹配到任何JSON对象,则游戏需要展示默认的货币价格。

调用代码示例:

import com.dh.DHSDKHelper;

import java.util.ArrayList;

ArrayList<String> skus = new ArrayList<>();
skus.add("com.dianhun.mdzz.b28");
skus.add("com.dianhun.mdzz.c150");

/**
* @param activity 上下文
* @param skus SKUS
* @param sdkCallback 回调对象
*/
DHSDKHelper.getInstance().getPlatform().querySkus(PayActivity.this, skus, sdkCallback);

回调对象示例如下:

public class DHSDKCallback implements IDHSDKCallback {
@Override
public void onDHSDKResult(int requestCode, int resultCode, String resultData) {
switch (requestCode) {
case DHSDKConst.REQ_SKUS:
// 查询结果
if (resultCode == DHSDKConst.RET_OK) {
// 查询成功
} else if (resultCode == DHSDKConst.RET_FAIL) {
// 查询失败
}
break;
default:
// 其他结果
break;
}
}
}

GooglePlay示例:requestData

[
{
"originalData": "{\"productId\":\"com.dianhun.mdzz.c150\",\"type\":\"inapp\",\"price\":\"US$4.99\",\"price_amount_micros\":4990000,\"price_currency_code\":\"USD\",\"title\":\"新春新生礼 (BarbarQ)\",\"description\":\"购买后可获得150宝石与新春宠物:吉祥\"}",
"productCurrency": "USD",
"productDescription": "购买后可获得150宝石与新春宠物:吉祥",
"productId": "com.dianhun.mdzz.c150",
"productName": "新春新生礼 (BarbarQ)",
"productPrice": "US$4.99",
"productTitle": "新春新生礼 (BarbarQ)"
},
{
"originalData": "{\"productId\":\"com.dianhun.mdzz.b28\",\"type\":\"inapp\",\"price\":\"US$3.99\",\"price_amount_micros\":3990000,\"price_currency_code\":\"USD\",\"title\":\"超值月卡 (BarbarQ)\",\"description\":\"花费28元,立即获得150原谅宝石;购买后30天内,每天额外获得20原谅宝石。\"}",
"productCurrency": "USD",
"productDescription": "花费28元,立即获得150原谅宝石;购买后30天内,每天额外获得20原谅宝石。",
"productId": "com.dianhun.mdzz.b28",
"productName": "超值月卡 (BarbarQ)",
"productPrice": "US$3.99",
"productTitle": "超值月卡 (BarbarQ)"
}
]
参数类型说明
originalDataString渠道返回的原始数据 , 一般情况下不用解析,根据不同发行渠道不同 .
productCurrencyString货币码
productIdString道具ID
productNameString道具名称
productPriceString道具价格
productTitleString道具标题

4、谷歌商店应用评价(选接)

import com.dh.DHSDKConst;
import com.dh.DHSDKHelper;
import com.dh.callback.IDHSDKCallback;
import com.dh.framework.utils.DHPluginParam;

String param = DHPluginParam.Builder()
.put("plugin_type", "google")
.put("unionsdk_type", "platform")
.put("event_type", "review")
.toString();

/**
* @param activity 上下文
* @param sdkCallback 回调对象
*/
DHSDKHelper.getInstance().exec(activity, param, new IDHSDKCallback() {
@Override
public void onDHSDKResult(int requestCode, int resultCode, String resultData) {
switch (requestCode) {
case 40:
// 评价结果
if (resultCode == DHSDKConst.RET_OK) {
// 评价成功
} else if (resultCode == DHSDKConst.RET_FAIL) {
// 评价失败
}
break;
default:
// 其他结果
break;
}
}
});

5、Taptap强制更新(选接)

import com.dh.DHSDKConst;
import com.dh.DHSDKHelper;
import com.dh.callback.IDHSDKCallback;
import com.dh.framework.utils.DHPluginParam;

String param = DHPluginParam.Builder()
.put("plugin_type", "tools")
.put("unionsdk_type", "platform")
.put("event_type", "forceUpdateGame")
.toString();

/**
* @param activity 上下文
* @param sdkCallback 回调对象
*/
DHSDKHelper.getInstance().exec(activity, param, new IDHSDKCallback() {
@Override
public void onDHSDKResult(int requestCode, int resultCode, String resultData) {
switch (requestCode) {
case 106:
// 强更结果
if (resultCode == DHSDKConst.RET_FAIL) {
// 强更失败,用户取消强制更新,或者调用失败
}
break;
default:
// 其他结果
break;
}
}
});

6、MTR网络检测

注意

玩家无法连接服务时可调用该接口,正常游戏千万不能调用,否则会带来卡顿。 调用接口之前,游戏最好自定义弹窗提示收集玩家网络信息,可能带来卡顿。玩家同意后再调用

String jsonstring = DHPluginParam.Builder()
.put("appid", "") // appid
.put("areaid", "") // 大区ID或者服务器ID
.put("uid", "1") // 角色id
.put("host", "www.test.cn") // 服务器域名 例如 www.test.cn,禁止带https或接口路径
.toString();

String param = DHPluginParam.Builder()
.put("plugin_type", "tools") //固定字段
.put("unionsdk_type", "platform") //固定字段
.put("event_type", "mtr") //固定字段
.put("event_key", "") //固定字段
.put("jsonstring", jsonstring)
.toString();

DHSDKHelper.getInstance().exec(this, param, new IDHSDKCallback() {

@Override
public void onDHSDKResult(int arg0, int arg1, String arg2) {
Log.d(arg2);
}
});

无回调