|
发表于 2025-5-12 15:54:46
|
查看全部
- public String ucApiPost(String module, String action, Map<String, Object> arg) {
- StringBuffer s = new StringBuffer();
- String sep = "";
- //foreach(arg as k => v) {
- for (String k : arg.keySet()) {
- //k = (k);
- Object v = arg.get(k);
- k = urlencode(k);
- if (v.getClass().isAssignableFrom(Map.class)) {
- String s2 = "";
- String sep2 = "";
- //foreach(v as k2 => v2) {
- for (String k2 : ((Map<String, Object>) v).keySet()) {
- Object v2 = ((Map<String, Object>) v).get(k2);
- k2 = urlencode(k2);
- s2 += sep2 + "{" + k + "}[" + k2 + "]=" + urlencode(ucStripslashes(String.valueOf(v2)));
- sep2 = "&";
- }
- s.append(sep).append(s2);
- } else {
- s.append(sep).append(k).append("=").append(urlencode(ucStripslashes(String.valueOf(v))));
- }
- sep = "&";
- }
- String postdata = ucApiRequestdata(module, action, s.toString(), "");
- return ucFopen2(UC_API + "/index.php", 500000, postdata, "", true, UC_IP, 20, true);
- // return ucFopen2(UC_API, 500000, postdata, "", true, UC_IP, 20, true);
- }
- /**
- * 构造发送给用户中心的请求数据
- *
- * @param module 请求的模块
- * @param action 请求的动作
- * @param arg 参数(会加密的方式传送)
- * @param extra 附加参数(传送时不加密)
- * @return string
- */
- protected String ucApiRequestdata(String module, String action, String arg, String extra) {
- String input = ucApiInput(arg, module, action);
- String post = "m=" + module + "&a=" + action + "&inajax=2&release=" + UC_CLIENT_RELEASE + "&input=" + input + "&appid=" + UC_APPID + extra;
- return post;
- }
- protected String ucApiUrl(String module, String action, String arg, String extra) {
- String url = UC_API + "/index.php?" + ucApiRequestdata(module, action, arg, extra);
- return url;
- }
- public String ucApiInput(String data, String module, String action) {
- data = data + "&m="+ module + "&a=" + action + "&appid=" + UC_APPID;
- //String s = data;
- //String s = urlencode(uc_authcode(data+"&agent="+md5(_SERVER["HTTP_USER_AGENT"])+"&time="+time(), "ENCODE", UC_KEY));
- String s = urlencode(ucAuthcode(data + "&agent=" + md5(HTTP_USER_AGENT) + "&time=" + time(), "ENCODE", UC_KEY));
- //String s = urlencode(ucAuthcode(data + "&agent=" + md5("") + "&time=" + time(), "ENCODE", UC_KEY));
- return s;
- }
复制代码
我的版本是3.5的discuz,ucenter2.0,也报"Access denied for agent changed"这个错 ,client代码中,也都按照“专家”的步骤实现了。搞不懂哪里的问题了
|
|