陈士柏 2 gadi atpakaļ
vecāks
revīzija
6c27982ee2
1 mainītis faili ar 31 papildinājumiem un 0 dzēšanām
  1. 31 0
      mhotel/src/com/happy/common/http/Get_airticle.java

+ 31 - 0
mhotel/src/com/happy/common/http/Get_airticle.java

@@ -0,0 +1,31 @@
+package com.happy.common.http;
+
+import com.alibaba.fastjson.JSONObject;
+import com.google.gson.Gson;
+import com.happy.Model.weixin.AccessToken;
+import com.happy.Until.HttpUtils;
+
+public class Get_airticle {
+
+    public static String get(int page, int rows) throws Exception {
+        Gson gson = new Gson();
+        String appid = "wx19d0b6ab36feedf4";
+        String secret = "309fca4f1a682e6c3d3ecf3b577b0707";
+        int start = (page - 1) * rows;// 每页的起始下标
+        String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid="
+                + appid + "&secret=" + secret;
+        String access_token = HttpUtils.get(url);
+        System.out.println(access_token);
+        access_token = gson.fromJson(access_token, AccessToken.class).getAccess_token();
+        System.out.println(access_token);
+        JSONObject data = new JSONObject();
+        data.put("offset", start);
+        data.put("count", rows);
+        data.put("no_content", 0);
+        return HttpsClient.sendJson("https://api.weixin.qq.com/cgi-bin/freepublish/batchget?access_token="+access_token, data);
+    }
+
+    public static void main(String[] args) throws Exception {
+        System.out.println(get(1,6));
+    }
+}