diff --git a/app/build.gradle b/app/build.gradle index d9f7527c0f..44127d6c9e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -87,11 +87,6 @@ android { buildConfigField "String", "WECHAT_SECRET", "\"${WECHAT_SECRET}\"" buildConfigField "String", "TENCENT_APPID", "\"${TENCENT_APPID}\"" buildConfigField "String", "WEIBO_APPKEY", "\"${WEIBO_APPKEY}\"" - buildConfigField "String", "TD_APPID", "\"${TD_APPID}\"" - buildConfigField "String", "LETO_APPID", "\"${LETO_APPID}\"" - buildConfigField "String", "TTAD_APPID", "\"${TTAD_APPID}\"" - buildConfigField "String", "DOUYIN_CLIENTKEY", "\"${DOUYIN_CLIENTKEY}\"" - buildConfigField "String", "DOUYIN_CLIENTSECRET", "\"${DOUYIN_CLIENTSECRET}\"" buildConfigField "String", "QUICK_LOGIN_APPID", "\"${QUICK_LOGIN_APPID}\"" buildConfigField "String", "QUICK_LOGIN_APPKEY", "\"${QUICK_LOGIN_APPKEY}\"" diff --git a/app/src/main/java/com/gh/common/constant/Config.java b/app/src/main/java/com/gh/common/constant/Config.java index f064ccb770..017348cd39 100644 --- a/app/src/main/java/com/gh/common/constant/Config.java +++ b/app/src/main/java/com/gh/common/constant/Config.java @@ -54,15 +54,10 @@ public class Config { public static final String WECHAT_SECRET = BuildConfig.WECHAT_SECRET; public static final String TENCENT_APPID = BuildConfig.TENCENT_APPID; public static final String WEIBO_APPKEY = BuildConfig.WEIBO_APPKEY; - public static final String LETO_APPID = BuildConfig.LETO_APPID; - public static final String TTAD_APPID = BuildConfig.TTAD_APPID; - public static final String DOUYIN_CLIENTKEY = BuildConfig.DOUYIN_CLIENTKEY; - public static final String DOUYIN_CLIENTSECRET = BuildConfig.DOUYIN_CLIENTSECRET; public static final String QUICK_LOGIN_APPID = BuildConfig.QUICK_LOGIN_APPID; public static final String QUICK_LOGIN_APPKEY = BuildConfig.QUICK_LOGIN_APPKEY; // http://www.ghzs666.com/article/${articleId}.html public static final String URL_ARTICLE = "http://www.ghzs666.com/article/"; // ghzs/ghzs666 统一 - public static final String PATCHES = "patches"; public static final String DEFAULT_CHANNEL = "GH_TEST3"; public static final String DEFAULT_CHANNEL_FOR_RELEASE = "GH_LOST"; // 正式包的缺省渠道,避免因渠道丢失而回落到测试渠道 diff --git a/app/src/main/java/com/gh/gamecenter/douyinapi/DouYinUserInfoThread.java b/app/src/main/java/com/gh/gamecenter/douyinapi/DouYinUserInfoThread.java index ddcfc70613..dc1cee7975 100644 --- a/app/src/main/java/com/gh/gamecenter/douyinapi/DouYinUserInfoThread.java +++ b/app/src/main/java/com/gh/gamecenter/douyinapi/DouYinUserInfoThread.java @@ -1,108 +1,108 @@ -package com.gh.gamecenter.douyinapi; - -import android.content.Context; -import android.text.TextUtils; - -import com.gh.common.constant.Config; -import com.lightgame.utils.Utils; - -import org.json.JSONObject; - -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URL; - -/** - * Created by khy on 30/06/17. - * 获取微信 accessToken 和 userInfo - */ - -public class DouYinUserInfoThread extends Thread { - - private Context mContext; - private OnUserInfoCallBackListener listener; - - private String mCode; - - //刷新access_token有效期 - private String refresh_token = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=APPID&grant_type=refresh_token&refresh_token=REFRESH_TOKEN"; - - public DouYinUserInfoThread(OnUserInfoCallBackListener listener, String code, Context context) { - this.listener = listener; - this.mCode = code; - this.mContext = context; - } - - @Override - public void run() { - super.run(); - try { - String tokenUrl = "https://open.douyin.com/oauth/access_token?client_key=" + - Config.DOUYIN_CLIENTKEY + "&client_secret=" + - Config.DOUYIN_CLIENTSECRET + "&code=" + - mCode + "&grant_type=authorization_code"; - String jsonResult = getJsonResultByUrlPath(tokenUrl); - JSONObject jsonObject = new JSONObject(jsonResult); - JSONObject data = jsonObject.optJSONObject("data"); - - String accessToken = data.optString("access_token"); - String refreshToken = data.optString("refresh_token"); - String openid = data.optString("open_id"); - String unionid = data.optString("unionid"); - long expiresIn = Long.parseLong(data.optString("expires_in")); - - if (!TextUtils.isEmpty(accessToken) && !TextUtils.isEmpty(openid) && !TextUtils.isEmpty(refreshToken) && listener != null) { -// String userInfoUrl = "https://api.weixin.qq.com/sns/userinfo?access_token=" + accessToken + "&openid=" + openid; -// String userInfo = getJsonResultByUrlPath(userInfoUrl); - JSONObject content = new JSONObject(); - content.put("openid", openid); - content.put("access_token", accessToken); - content.put("access_token_expire", Utils.getTime(mContext) + expiresIn); // 有效期 - content.put("refresh_token", refreshToken); -// content.put("refresh_token_expire", Utils.getTime(mContext) + 86400 * 30); // 有效期 30天 - content.put("unionid", unionid); - - listener.onComplete(content); - } else { - if (listener != null) { - listener.onError(); - } - } - } catch (Exception e) { - e.printStackTrace(); - if (listener != null) { - listener.onError(); - } - } - } - - private String getJsonResultByUrlPath(String path) throws Exception { - URL url = new URL(path); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - conn.setConnectTimeout(5000); - conn.setRequestMethod("GET"); - conn.setDoInput(true); - int code = conn.getResponseCode(); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - byte[] buffer = new byte[1024]; - int len; - Utils.log(DouYinUserInfoThread.class.getSimpleName(), "DouYinUserInfoThread-getJsonResultByUrlPath::" + code); - if (code == 200) { - InputStream is = conn.getInputStream(); - while ((len = is.read(buffer)) != -1) { - baos.write(buffer, 0, len); - } - String str = new String(baos.toByteArray()); - Utils.log(DouYinUserInfoThread.class.getSimpleName(), "DouYinUserInfoThread-Body::" + str); - return str; - } - return null; - } - - public interface OnUserInfoCallBackListener { - void onComplete(JSONObject content); - - void onError(); - } -} +//package com.gh.gamecenter.douyinapi; +// +//import android.content.Context; +//import android.text.TextUtils; +// +//import com.gh.common.constant.Config; +//import com.lightgame.utils.Utils; +// +//import org.json.JSONObject; +// +//import java.io.ByteArrayOutputStream; +//import java.io.InputStream; +//import java.net.HttpURLConnection; +//import java.net.URL; +// +///** +// * Created by khy on 30/06/17. +// * 获取微信 accessToken 和 userInfo +// */ +// +//public class DouYinUserInfoThread extends Thread { +// +// private Context mContext; +// private OnUserInfoCallBackListener listener; +// +// private String mCode; +// +// //刷新access_token有效期 +// private String refresh_token = "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=APPID&grant_type=refresh_token&refresh_token=REFRESH_TOKEN"; +// +// public DouYinUserInfoThread(OnUserInfoCallBackListener listener, String code, Context context) { +// this.listener = listener; +// this.mCode = code; +// this.mContext = context; +// } +// +// @Override +// public void run() { +// super.run(); +// try { +// String tokenUrl = "https://open.douyin.com/oauth/access_token?client_key=" + +// Config.DOUYIN_CLIENTKEY + "&client_secret=" + +// Config.DOUYIN_CLIENTSECRET + "&code=" + +// mCode + "&grant_type=authorization_code"; +// String jsonResult = getJsonResultByUrlPath(tokenUrl); +// JSONObject jsonObject = new JSONObject(jsonResult); +// JSONObject data = jsonObject.optJSONObject("data"); +// +// String accessToken = data.optString("access_token"); +// String refreshToken = data.optString("refresh_token"); +// String openid = data.optString("open_id"); +// String unionid = data.optString("unionid"); +// long expiresIn = Long.parseLong(data.optString("expires_in")); +// +// if (!TextUtils.isEmpty(accessToken) && !TextUtils.isEmpty(openid) && !TextUtils.isEmpty(refreshToken) && listener != null) { +//// String userInfoUrl = "https://api.weixin.qq.com/sns/userinfo?access_token=" + accessToken + "&openid=" + openid; +//// String userInfo = getJsonResultByUrlPath(userInfoUrl); +// JSONObject content = new JSONObject(); +// content.put("openid", openid); +// content.put("access_token", accessToken); +// content.put("access_token_expire", Utils.getTime(mContext) + expiresIn); // 有效期 +// content.put("refresh_token", refreshToken); +//// content.put("refresh_token_expire", Utils.getTime(mContext) + 86400 * 30); // 有效期 30天 +// content.put("unionid", unionid); +// +// listener.onComplete(content); +// } else { +// if (listener != null) { +// listener.onError(); +// } +// } +// } catch (Exception e) { +// e.printStackTrace(); +// if (listener != null) { +// listener.onError(); +// } +// } +// } +// +// private String getJsonResultByUrlPath(String path) throws Exception { +// URL url = new URL(path); +// HttpURLConnection conn = (HttpURLConnection) url.openConnection(); +// conn.setConnectTimeout(5000); +// conn.setRequestMethod("GET"); +// conn.setDoInput(true); +// int code = conn.getResponseCode(); +// ByteArrayOutputStream baos = new ByteArrayOutputStream(); +// byte[] buffer = new byte[1024]; +// int len; +// Utils.log(DouYinUserInfoThread.class.getSimpleName(), "DouYinUserInfoThread-getJsonResultByUrlPath::" + code); +// if (code == 200) { +// InputStream is = conn.getInputStream(); +// while ((len = is.read(buffer)) != -1) { +// baos.write(buffer, 0, len); +// } +// String str = new String(baos.toByteArray()); +// Utils.log(DouYinUserInfoThread.class.getSimpleName(), "DouYinUserInfoThread-Body::" + str); +// return str; +// } +// return null; +// } +// +// public interface OnUserInfoCallBackListener { +// void onComplete(JSONObject content); +// +// void onError(); +// } +//}