这里不是挂,不是反编译游戏,只是查询一些数据而已:
可以猜猜是啥游戏的数据,后续看这篇文章的内容值不值得发后续吧,主要是图个乐呵
话不多说直接上代码,大哥们可以看看有没有什么问题啥的
package com.mj.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import okhttp3.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import static com.mj.utils.requestUtils.HttpRequest.sendPost;
import static com.mj.utils.PostRequestWithObjectExample.doUrl;
public class YingDiUtils {
public static String RoleID(String account){
//定义需要返回的数据
HashMap<String, Object> itemData = new HashMap<>();
String token = "";//需要自己抓包
String userId = "";//需要自己抓包
HashMap<String, String> data1 = new HashMap<>();
data1.put("cClientVersionCode","68220107847551");
data1.put("cClientVersionName","7.82.0315");
data1.put("cSystem","ios");
data1.put("gameId","20001");
data1.put("keyword",""+account);
data1.put("token",token);
data1.put("userId",userId);
String params = "";
for (String s : data1.keySet()) {
params+= s+"="+data1.get(s)+"&";
}
params = params.substring(0,params.length()-1);
JSONObject jsonObject = sendPost("https://ssl.kohsocialapp.qq.com:10001/search/getresults", params, null);
if (jsonObject.getInteger("returnCode") == 1){
return null;
}
System.out.println(JSON.toJSONString(jsonObject,true));
boolean roleType = true;
//获取到返回的数据
JSONArray array = jsonObject.getJSONArray("data");
for (int i = 0; i < array.size(); i++) {
JSONObject jsonObject1 = array.getJSONObject(i);
if ("stranger".equals(jsonObject1.getString("type"))){
roleType = false;
}
}
if (roleType)return null;
//获取到roleID
String roleId = array.getJSONObject(0).getJSONArray("list").getJSONObject(0).getString("roleId");
return roleId;
}
public static String PiFu(String token,String userid,String roleid) throws IOException {
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
RequestBody body = RequestBody.create(mediaType, "roleId="+roleid+"&cClientVersionName=7.84.0906&token="+token+"&userId="+userid);
Request request = new Request.Builder()
.url("https://ssl.kohsocialapp.qq.com:10001/play/h5getheroskinlist")
.post(body)
.addHeader("token", token)
.addHeader("userId", userid)
.addHeader("content-type", "application/x-www-form-urlencoded")
.build();
try {
Response response = client.newCall(request).execute();
String responseBody = response.body().string();
return responseBody;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public static ResultUtils Get(String account,String token,String userId) throws IOException {
//定义需要返回的数据
HashMap<String, Object> itemData = new HashMap<>();
HashMap<String, String> data1 = new HashMap<>();
data1.put("cClientVersionCode","68220107847551");
data1.put("cClientVersionName","7.82.0315");
data1.put("cSystem","ios");
data1.put("gameId","20001");
data1.put("keyword",""+account);
data1.put("token",token);
data1.put("userId",userId);
String params = "";
for (String s : data1.keySet()) {
params+= s+"="+data1.get(s)+"&";
}
params = params.substring(0,params.length()-1);
JSONObject jsonObject = sendPost("https://ssl.kohsocialapp.qq.com:10001/search/getresults", params, null);
if (jsonObject.getInteger("returnCode") == 1){
return ResultUtils.err();
}
boolean roleType = true;
//获取到返回的数据
JSONArray array = jsonObject.getJSONArray("data");
for (int i = 0; i < array.size(); i++) {
JSONObject jsonObject1 = array.getJSONObject(i);
if ("stranger".equals(jsonObject1.getString("type"))){
roleType = false;
}
}
if (roleType)return ResultUtils.err();
//获取到roleID
String roleId = array.getJSONObject(0).getJSONArray("list").getJSONObject(0).getString("roleId");
System.out.println("roleID="+roleId);
System.out.println("_--------------------------------------------------------------------");
HashMap<String, String> baseHand = new HashMap<>();
baseHand.put("token",token);
baseHand.put("userId",userId);
baseHand.put("Content-Type","application/json");
HashMap<String, Object> putData = new HashMap<>();
putData.put("apiVersion", 2);
putData.put("targetUserId", account);
putData.put("recommendPrivacy", 0);
putData.put("targetRoleId", roleId);
putData.put("refresh", true);
//初始化数据
String post = doUrl("https://kohcamp.qq.com/game/profile/index", "POST", JSON.toJSONString(putData,true), baseHand);
JSONObject resData = JSONObject.parseObject(post);
if (resData.getInteger("result") == 1) return ResultUtils.err();
JSONArray items = resData.getJSONObject("data").getJSONObject("head").getJSONArray("mods");
for (int i = 0; i < items.size(); i++) {
Integer modId = items.getJSONObject(i).getInteger("modId");
if (modId == 201){
itemData.put("heroNum",items.getJSONObject(i).getString("content").split("/")[0]);
}
if (modId == 202){
itemData.put("skinNum",items.getJSONObject(i).getString("content").split("/")[0]);
}
if (modId == 304){
itemData.put("fight",items.getJSONObject(i).getString("content"));
}
if (modId == 401){
itemData.put("quantity",items.getJSONObject(i).getString("content"));
}
if (modId == 408){
itemData.put("mvp",items.getJSONObject(i).getString("content"));
}
if (modId == 409){
itemData.put("percentage",items.getJSONObject(i).getString("content"));
}
}
List<JSONObject> areaList = new ArrayList<>();
JSONArray resArray = resData.getJSONObject("data").getJSONArray("roleList");
for (int i = 0; i < resArray.size(); i++) {
JSONObject item = resArray.getJSONObject(i);
if (item.getInteger("isCommon") == 1){
areaList.add(item);
}
}
if (areaList.size() >0){
itemData.put("areaId",areaList.get(areaList.size()-1).getString("areaId"));
String serverId = areaList.get(areaList.size() - 1).getString("serverId");
serverId = serverId.substring(1,serverId.length());
int si = Integer.parseInt(serverId) - 10;
itemData.put("serverId",si);
}else{
System.out.println("营地号错误");
return ResultUtils.err();
}
System.out.println(JSON.toJSONString(itemData,true));
String s = PiFu(token,userId,roleId);
JSONObject userBase = JSONObject.parseObject(s);
String heroSkinList = userBase.getJSONObject("data").getString("heroSkinList");
//用户隐藏
if (!StringUtils.isNotBlank(heroSkinList))return ResultUtils.err();
// 所有的基础信息
JSONObject skinCountInfo = userBase.getJSONObject("data").getJSONObject("skinCountInfo");
//皮肤类型:
JSONArray skinTypeList = skinCountInfo.getJSONArray("skinTypeList");
//所有的皮肤
JSONObject AllPF = userBase.getJSONObject("data").getJSONObject("heroSkinConfList");
JSONUtil.writeJsonFile("/static/all.json", JSON.toJSONString(AllPF,true));
ArrayList<Integer> roles = new ArrayList<>();
ArrayList<String> roleNames = new ArrayList<>();
JSONArray array1 = JSONArray.parseArray(heroSkinList);
for (int i = 0; i < array1.size(); i++) {
Integer skinID = array1.getJSONObject(i).getInteger("skinId");
roles.add(skinID);
roleNames.add(array1.getJSONObject(i).getString("szTitle"));
}
String title = "";
itemData.put("roles",roles);
itemData.put("roleNames",roleNames);
itemData.put("skin",title);
return ResultUtils.ok(itemData);
}
}