|
- 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,也不報這個錯,client代碼中,也都按照“專家”的步驟實現了。搞不懂哪里的問題了 |
|