kujiale.java 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. package com.cnd3b.utility.kujiale;
  2. import com.cnd3b.utility.Encryption;
  3. import com.alibaba.fastjson.JSONArray;
  4. import com.alibaba.fastjson.JSONObject;
  5. import com.cnd3b.utility.WebRequest;
  6. import java.util.ArrayList;
  7. public class kujiale {
  8. private String appKey = "";
  9. private String appSecret = "";
  10. public kujiale(String appKey, String appSecret) {
  11. this.appKey = appKey;
  12. this.appSecret = appSecret;
  13. }
  14. /**
  15. * 获取用户列表
  16. *
  17. * @param start
  18. * @param num
  19. */
  20. public void getUserList(int start, int num) {
  21. final long timestamp = System.currentTimeMillis();
  22. // 签名生成的两种方式之一,在有appuid入参的情况下,需要将appuid也加入计算。
  23. Encryption encryption = new Encryption();
  24. final String sign = encryption.Encode_MD5(this.appSecret + this.appKey + timestamp);
  25. WebRequest webRequest = new WebRequest();
  26. String a = webRequest.doGet("https://openapi.kujiale.com/v2/user?appkey=" + this.appKey + "&timestamp=" + timestamp + "&sign=" + sign + "&start=" + start + "&num=" + num);
  27. System.err.println(a);
  28. }
  29. /**
  30. * 获取方案分类列表
  31. *
  32. * @param start
  33. * @param num
  34. * @param appuid
  35. */
  36. public void getClassList(int start, int num, String appuid) {
  37. final long timestamp = System.currentTimeMillis();
  38. // 签名生成的两种方式之一,在有appuid入参的情况下,需要将appuid也加入计算。
  39. Encryption encryption = new Encryption();
  40. final String sign = encryption.Encode_MD5(appSecret + appKey + appuid + timestamp);
  41. WebRequest webRequest = new WebRequest();
  42. String a = webRequest.doGet("https://openapi.kujiale.com/v2/design/tag/list?appkey=" + this.appKey + "&timestamp=" + timestamp + "&sign=" + sign + "&start=" + start + "&num=" + num + "&appuid=" + appuid);
  43. System.err.println(a);
  44. }
  45. /**
  46. * 获取用户方案
  47. *
  48. * @param start
  49. * @param num
  50. * @param appuid
  51. */
  52. public void getDesignList(int start, int num, String appuid) {
  53. final long timestamp = System.currentTimeMillis();
  54. // 签名生成的两种方式之一,在有appuid入参的情况下,需要将appuid也加入计算。
  55. Encryption encryption = new Encryption();
  56. final String sign = encryption.Encode_MD5(appSecret + appKey + appuid + timestamp);
  57. WebRequest webRequest = new WebRequest();
  58. String a = webRequest.doGet("https://openapi.kujiale.com/v2/design/list?appkey=" + this.appKey + "&timestamp=" + timestamp + "&sign=" + sign + "&start=" + start + "&num=" + num + "&appuid=" + appuid);
  59. System.err.println(a);
  60. }
  61. /**
  62. * 获取用户方案渲染图
  63. *
  64. * @param start
  65. * @param num
  66. * @param design_id
  67. */
  68. public void getDesignRender(int start, int num, String design_id) {
  69. final long timestamp = System.currentTimeMillis();
  70. // 签名生成的两种方式之一,在有appuid入参的情况下,需要将appuid也加入计算。
  71. Encryption encryption = new Encryption();
  72. final String sign = encryption.Encode_MD5(appSecret + appKey + timestamp);
  73. WebRequest webRequest = new WebRequest();
  74. String a = webRequest.doGet("https://openapi.kujiale.com/v2/renderpic/list?appkey=" + this.appKey + "&timestamp=" + timestamp + "&sign=" + sign + "&start=" + start + "&num=" + num + "&design_id=" + design_id);
  75. System.err.println(a);
  76. }
  77. /**
  78. * 获取用户方案漫游
  79. * @param appuid
  80. * @param design_id
  81. */
  82. // public void getDesignRoam(String appuid,String design_id) {
  83. // final long timestamp = System.currentTimeMillis();
  84. // // 签名生成的两种方式之一,在有appuid入参的情况下,需要将appuid也加入计算。
  85. // Encryption encryption = new Encryption();
  86. // final String sign = encryption.Encode_MD5(appSecret + appKey+appuid + timestamp);
  87. // WebRequest webRequest = new WebRequest();
  88. // String a = webRequest.doGet("https://openapi.kujiale.com/v2/pano/roam/list?appkey=" + this.appKey + "&timestamp=" + timestamp + "&sign=" + sign+"&appuid="+appuid +"&design_id="+design_id);
  89. // System.err.println(a);
  90. // }
  91. /**
  92. * 创建全屋漫游链接
  93. *
  94. * @param picIds
  95. */
  96. public void createDesignRoam(ArrayList<String> picIds) {
  97. final long timestamp = System.currentTimeMillis();
  98. // 签名生成的两种方式之一,在有appuid入参的情况下,需要将appuid也加入计算。
  99. Encryption encryption = new Encryption();
  100. final String sign = encryption.Encode_MD5(appSecret + appKey + timestamp);
  101. WebRequest webRequest = new WebRequest();
  102. JSONObject requestObject = new JSONObject();
  103. requestObject.put("override", false);
  104. JSONArray picIdsArray = new JSONArray();
  105. picIdsArray.addAll(picIds);
  106. requestObject.put("picIds", picIdsArray);
  107. System.err.println(requestObject.toJSONString());
  108. String a = webRequest.doPostKuJiaLe(requestObject.toJSONString(), "https://openapi.kujiale.com/v2/renderpic/pano?appkey=" + this.appKey + "&timestamp=" + timestamp + "&sign=" + sign);
  109. System.err.println(a);
  110. }
  111. public static void main(String args[]) {
  112. final String appKey = "E4cUIMIBeQ";
  113. final String appSecret = "5uumTJeJLQrp9r6HvZggG1muelv5OqnT";
  114. // new kujiale(appKey,appSecret).getUserList(0,10000);
  115. // new kujiale(appKey,appSecret).getClassList(0,10,"102415");
  116. // new kujiale(appKey,appSecret).getDesignList(0,10,"102415");
  117. // new kujiale(appKey,appSecret).getDesignRender(0,10,"3FO49BG1RTW7");
  118. // new kujiale(appKey,appSecret).getDesignRoam("102415","3FO49BG1RTW7");
  119. ArrayList<String> list = new ArrayList<>();
  120. list.add("3FNYSU9NDR0R");
  121. list.add("3FNYSUBGODHE");
  122. list.add("3FNYYJ5N2WH1");
  123. list.add("3FNYYJ63OGMH");
  124. new kujiale(appKey, appSecret).createDesignRoam(list);
  125. }
  126. }