club_login/src/main/java/com/ljsd/sdk/KSManager.java

140 lines
4.6 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.ljsd.sdk;
import com.alibaba.fastjson.JSONObject;
import com.ljsd.controller.LoginSDKController;
import com.ljsd.util.BaseGlobal;
import com.ljsd.util.HttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
/**
* @version V1.0
* @ClassName: KSManager
* @Package com.ljsd.ks
* @Description: ${快手接入相关}
* @Author: zw
* @date: 2020/6/4 15:33
*/
public class KSManager {
private static final Logger LOGGER = LoggerFactory.getLogger(KSManager.class);
private static final String APP_ID = "ks681732397632875242";
public static String LOGIN_VERIFY_URL = "https://open.kuaishou.com/game/user_info";
public static String LOGIN_TEST_VERIFY_URL = "http://open.test.gifshow.com/game/user_info";
public static final String KUAI_SHOU = "KuaiShou";
private static String BT_LOGIN_VERIFY_URL = "https://supersdk.7pa.com/login/checkuserinfo";
private static String X7_LOGIN_VERIFY_URL = "https://api.x7sy.com/user/check_v4_login";
/**
* 幽谷登陆认证
*/
private static String YG_LOGIN_VERIFY_URL = "http://smi.648sy.com/yxywkldyzaqzf/auth";
public static String OPEN_SERVER_STRATEGY = "1"; // 开服策略1 按注册量开 2 按时间开
/**
* 快手登录验证
*
* @param gameId
* @param token
* @return
*/
public static String loginVerify(String gameId, String token, boolean isOnline) {
Map<String, String> param = new HashMap<>();
param.put("app_id", APP_ID);
param.put("game_id", gameId);
param.put("game_token", token);
String paramStr = HttpClient.joinParam(param);
String response = "";
if (isOnline) {
response = HttpClient.sendGet(LOGIN_VERIFY_URL, paramStr);
} else {
response = HttpClient.sendGet(LOGIN_TEST_VERIFY_URL, paramStr);
}
return response;
}
// public static void main(String[] args) {
// String gameId = "120592009db2d8e3eb07fb38a2730acf12";
// String token =
// "ChJvcGVucGxhdGZvcm0udG9rZW4SMAM7UR7xnKWv0WNlJUju9Fhg0onfcvYhIpfyuzOJMoEeR6r86eKwab60hbGDzvxckhoSiFj3919FQSKj7382Le0VBErzIiCsbZy5IGlecA9xQvQgIsZMfBZdr9XrpjhPDS9kN1g0ySgFMAE";
// String response = loginVerify(gameId, token,true);
// JSONObject jsonObject = JSONObject.parseObject(response);
// int result = jsonObject.getInteger("result");
// System.out.println(response);
// }
/**
* 幽谷 登录验证
*
* @param gameId
* @param token
* @return
*/
public static boolean ygLoginVerify(String gameId, String token) {
boolean isOnline = Boolean.parseBoolean(BaseGlobal.properties.getProperty("isOnline"));
if (!isOnline){
return true;
}
Map<String, String> param = new HashMap<>(2);
param.put("uid", gameId);
param.put("token", token);
String paramStr = HttpClient.joinParam(param);
String result = HttpClient.sendGet(YG_LOGIN_VERIFY_URL, paramStr);
JSONObject json = JSONObject.parseObject(result);
return json.getInteger("errno") == 0;
}
/**
* bt 登录验证
*
* @param gameId
* @param token
* @return
*/
public static boolean btLoginVerify(String gameId, String token) {
boolean isOnline = Boolean.parseBoolean(BaseGlobal.properties.getProperty("isOnline"));
if (!isOnline){
return true;
}
Map<String, String> param = new HashMap<>(2);
param.put("super_user_id", gameId);
param.put("token", token);
String result = HttpClient.sendPost(BT_LOGIN_VERIFY_URL, param);
JSONObject json = JSONObject.parseObject(result);
return json.getInteger("code") == 200;
}
/**
* x7 登录验证
*
* @param tokenkey
* @param sign
* @return
*/
public static JSONObject x7LoginVerify(String tokenkey, String sign) {
boolean isOnline = Boolean.parseBoolean(BaseGlobal.properties.getProperty("isOnline"));
if (!isOnline){
LOGGER.info("x7LoginVerify isOnline={} gameId={} token={}", isOnline, tokenkey, sign);
return null;
}
Map<String, String> param = new HashMap<>(2);
param.put("tokenkey", tokenkey);
param.put("sign", sign);
String result = HttpClient.sendPost(X7_LOGIN_VERIFY_URL, param);
JSONObject json = JSONObject.parseObject(result);
LOGGER.info("x7LoginVerify=====result={} json={}", result, json);
return json;
}
}