上传角色、区服信息
<h1>上传角色、区服信息</h1>
<p>接口调用场景 (<strong>以下场景必须调用,其它场景按需调用</strong>):</p>
<pre><code>1. 创建角色
2. 角色进入服务器
3. 角色升级
4. 加入帮派、变更帮派、退出帮派
5. 使用改名卡</code></pre>
<h2>接口定义</h2>
<pre><code>public void uploadRoleInfo(Context context, String[] infos, final NetCallBack netCallBack)</code></pre>
<h2>接口参数说明</h2>
<table>
<thead>
<tr>
<th>参数名</th>
<th>类型</th>
<th>是否必须</th>
<th>参数说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>app_id</td>
<td>String</td>
<td>是</td>
<td>必须游戏接入时分配的应用app_id</td>
</tr>
<tr>
<td>mem_id</td>
<td>String</td>
<td>是</td>
<td>登陆时提供给CP的用户id</td>
</tr>
<tr>
<td>server</td>
<td>String</td>
<td>是</td>
<td>游戏区服名称</td>
</tr>
<tr>
<td>server_id</td>
<td>String</td>
<td>是</td>
<td>游戏区服id</td>
</tr>
<tr>
<td>role</td>
<td>String</td>
<td>是</td>
<td>角色名称</td>
</tr>
<tr>
<td>role_id</td>
<td>String</td>
<td>是</td>
<td>角色id</td>
</tr>
<tr>
<td>guild</td>
<td>String</td>
<td>是</td>
<td>公会or帮派 默认传空(null,''),或传无</td>
</tr>
<tr>
<td>lever</td>
<td>String</td>
<td>是</td>
<td>等级</td>
</tr>
<tr>
<td>country</td>
<td>String</td>
<td>是</td>
<td>国家</td>
</tr>
<tr>
<td>power</td>
<td>String</td>
<td>是</td>
<td>战力</td>
</tr>
<tr>
<td>server_id_merge</td>
<td>String</td>
<td>是</td>
<td>合服后区服id</td>
</tr>
<tr>
<td>sign</td>
<td>String</td>
<td>是</td>
<td>必须的参数校验</td>
</tr>
</tbody>
</table>
<h2>接口回调说明</h2>
<p>无</p>
<h2>调用完整代码</h2>
<pre><code>String app_id = &quot;60024&quot;;
String mem_id = &quot;20&quot;;
String server = &quot;广东一区&quot;;
String role = &quot;张三&quot;;
String guild = &quot;联盟&quot;;
String lever = &quot;999&quot;;
String server_id = &quot;1&quot;;
String role_id = &quot;2&quot;;
String country = &quot;国家&quot;;
String power = &quot;战力&quot;;
String server_id_merge = &quot;2&quot;;
String sign = md5(&quot;app_id=&quot;+app_id+&quot;&amp;mem_id=&quot;+mem_id
+&quot;&amp;server=&quot;+server+&quot;&amp;server_id=&quot;+server_id
+&quot;&amp;role=&quot;+role+&quot;&amp;role_id=&quot;+role_id
+&quot;&amp;guild=&quot;+guild+&quot;&amp;lever=&quot;+lever
+&quot;&amp;country=&quot;+country+&quot;&amp;power=&quot;+power
+&quot;&amp;server_id_merge=&quot;+server_id_merge);
String[] infos = {app_id,mem_id,server,server_id,role,role_id,guild,lever,country,power,server_id_merge,sign};
sdkManager.uploadRoleInfo(MainActivity.this, infos, new NetCallBack() {
@Override
public void onInitSuccess(ResultCode result) {
//数据提交成功
Toast.makeText(MainActivity.this,&quot;onInitSuccess&quot;,Toast.LENGTH_LONG).show();
}
@Override
public void onInitFail(ResultCode result) {
//数据提交失败
Toast.makeText(MainActivity.this,&quot;onInitFail&quot;,Toast.LENGTH_LONG).show();
}
});
/** 计算字符串MD5值* */
public static String md5(String string) {
if (TextUtils.isEmpty(string)) {
return &quot;&quot;;
}
MessageDigest md5 = null;
try {
md5 = MessageDigest.getInstance(&quot;MD5&quot;);
byte[] bytes = md5.digest(string.getBytes());
String result = &quot;&quot;;
for (byte b : bytes) {
String temp = Integer.toHexString(b &amp; 0xff);
if (temp.length() == 1) {
temp = &quot;0&quot; + temp;
}
result += temp;
}
return result;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return &quot;&quot;;
}</code></pre>