| | |
| | | String result = TaoBaoHttpUtil.taoKeGet(params);
|
| | | JSONObject data = JSONObject.fromObject(result);
|
| | | if (data != null) {
|
| | | if (data.optJSONObject("error_response") != null
|
| | | && data.optJSONObject("error_response").optInt("code") == 7) {
|
| | | if (data.optJSONObject("error_response") != null && data.optJSONObject("error_response").optInt("code") == 7
|
| | | && "accesscontrol.limited-by-app-access-count"
|
| | | .equalsIgnoreCase(data.optJSONObject("error_response").optString("sub_code"))) {
|
| | | reportAppInvalid(app.getAppKey());
|
| | | TaoKeLogHelper.error(params, result);
|
| | | try {
|
| | | EmergencyUtil.baoJin("monitor-error-tb-app-limit-" + params.get("app_key"),
|
| | | "淘宝APPKey请求限制【" + params.get("app_key") + "】", new String[] { "18581318252" });
|
| | | } catch (Exception e1) {
|
| | | }
|
| | | throw new TaoKeApiException(TaoKeApiException.CODE_APPKEY_LIMIT, "淘宝请求限制:" + result, params);
|
| | | } else if (data.optJSONObject("error_response") != null) {
|
| | | throw new TaoKeApiException(TaoKeApiException.CODE_API_ERROR, result, params);
|
| | |
| | | } else
|
| | | throw new TaoKeApiException(TaoKeApiException.CODE_OTHER, ":" + result, params);
|
| | | reValid(app.getAppKey());
|
| | | return data;
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 服务商请求
|
| | | * @Title: baseScRequest
|
| | | * @Description: |
| | | * @param param
|
| | | * @param session
|
| | | * @return
|
| | | * @throws TaoKeApiException |
| | | * JSONObject 返回类型
|
| | | * @throws
|
| | | */
|
| | | public static JSONObject baseScRequest(Map<String, String> param,TaoKeAppInfo app, String session,String targetAppKey) throws TaoKeApiException {
|
| | | // 复制params
|
| | | Map<String, String> params = new HashMap<>();
|
| | | if (param != null) {
|
| | | Iterator<String> its = param.keySet().iterator();
|
| | | while (its.hasNext()) {
|
| | | String key = its.next();
|
| | | params.put(key, param.get(key));
|
| | | }
|
| | | }
|
| | |
|
| | | if (app == null)
|
| | | throw new TaoKeApiException(TaoKeApiException.CODE_NO_USE, "无appkey可用");
|
| | | // 签名
|
| | | params.put("app_key", app.getAppKey());
|
| | | params.put("sign_method", "md5");
|
| | | params.put("v", "2.0");
|
| | | params.put("timestamp", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss"));
|
| | | params.put("format", "json");
|
| | | params.put("session", session);
|
| | | // params.put("target_app_key", targetAppKey);
|
| | | params.put("sign", getSign(params, "md5", app).toUpperCase());
|
| | | String result = TaoBaoHttpUtil.taoKeGet(params);
|
| | | JSONObject data = JSONObject.fromObject(result);
|
| | | if (data != null) {
|
| | | if (data.optJSONObject("error_response") != null && data.optJSONObject("error_response").optInt("code") == 7
|
| | | && "accesscontrol.limited-by-app-access-count"
|
| | | .equalsIgnoreCase(data.optJSONObject("error_response").optString("sub_code"))) {
|
| | | reportAppInvalid(app.getAppKey());
|
| | | TaoKeLogHelper.error(params, result);
|
| | | try {
|
| | | EmergencyUtil.baoJin("monitor-error-tb-app-limit-" + params.get("app_key"),
|
| | | "淘宝APPKey请求限制【" + params.get("app_key") + "】", new String[] { "18581318252" });
|
| | | } catch (Exception e1) {
|
| | | }
|
| | | throw new TaoKeApiException(TaoKeApiException.CODE_APPKEY_LIMIT, "淘宝请求限制:" + result, params);
|
| | | } else if (data.optJSONObject("error_response") != null) {
|
| | | throw new TaoKeApiException(TaoKeApiException.CODE_API_ERROR, result, params);
|
| | | }
|
| | | } else
|
| | | throw new TaoKeApiException(TaoKeApiException.CODE_OTHER, ":" + result, params);
|
| | | // reValid(app.getAppKey());
|
| | | return data;
|
| | | }
|
| | |
|
| | |
| | | String result = TaoBaoHttpUtil.taoKeGet(params);
|
| | | JSONObject data = JSONObject.fromObject(result);
|
| | | if (data != null) {
|
| | | if (data.optJSONObject("error_response") != null
|
| | | && data.optJSONObject("error_response").optInt("code") == 7) {
|
| | | if (data.optJSONObject("error_response") != null && data.optJSONObject("error_response").optInt("code") == 7
|
| | | && "accesscontrol.limited-by-app-access-count"
|
| | | .equalsIgnoreCase(data.optJSONObject("error_response").optString("sub_code"))) {
|
| | | reportAppInvalid(app.getAppKey());
|
| | | throw new TaoKeApiException(TaoKeApiException.CODE_APPKEY_LIMIT, "淘宝请求限制:" + result, params);
|
| | | } else if (data.optJSONObject("error_response") != null) {
|
| | |
| | | TaoKeLogHelper.error(e.getParams(), e.getMsg());
|
| | | if (e.getCode() == TaoKeApiException.CODE_API_ERROR) {
|
| | | result = e.getMsg();
|
| | | } else if (e.getCode() == TaoKeApiException.CODE_APPKEY_LIMIT) {
|
| | | try {
|
| | | EmergencyUtil.baoJin("monitor-error-tb-app-limit-" + params.get("app_key"),
|
| | | "淘宝APPKey请求限制【" + params.get("app_key") + "】", new String[] { "18581318252" });
|
| | | } catch (Exception e1) {
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|