|
|
@@ -0,0 +1,39 @@
|
|
|
+package com.mrxu.framework.common.xcx.api;
|
|
|
+
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.mrxu.framework.common.weixin.base.WxHttp;
|
|
|
+import com.mrxu.framework.common.weixin.base.WxResult;
|
|
|
+import com.mrxu.framework.common.xcx.bean.Categories;
|
|
|
+
|
|
|
+// 小程序类目
|
|
|
+// https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/category/getallcategories.html
|
|
|
+public class CategoriesApi {
|
|
|
+
|
|
|
+ // 获取已设置的所有类目
|
|
|
+ private static final String getcategory = "https://api.weixin.qq.com/cgi-bin/wxopen/getcategory?access_token=";
|
|
|
+
|
|
|
+ // 添加类目
|
|
|
+ private static final String addcategory = "https://api.weixin.qq.com/cgi-bin/wxopen/addcategory?access_token=";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取已设置的所有类目
|
|
|
+ * https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/category/getcategory.html
|
|
|
+ */
|
|
|
+ public static Categories getcategory(String accessToken) {
|
|
|
+ Categories rs = WxHttp.get(Categories.class,getcategory+accessToken,null);
|
|
|
+ return rs;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 添加类目
|
|
|
+ // https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/category/addcategory.html
|
|
|
+ public static WxResult addcategory(String accessToken,
|
|
|
+ JSONArray categories) {
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("categories", categories);
|
|
|
+ WxResult rs = WxHttp.post(WxResult.class,addcategory+accessToken,json);
|
|
|
+ return rs;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|