|
@@ -14,25 +14,31 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@SpringBootTest(classes = NbjkApplication.class)
|
|
|
@RunWith(SpringRunner.class)
|
|
|
public class WxGzhTest {
|
|
|
|
|
|
@Autowired
|
|
|
- private IWxGzhService wxGzhServicee;
|
|
|
+ private IWxGzhService wxGzhService;
|
|
|
@Autowired
|
|
|
private IWxService wxService;
|
|
|
|
|
|
@Test
|
|
|
public void getUserInfo() throws IOException {
|
|
|
- String token = wxGzhServicee.getGzhToken();
|
|
|
- WxMaterialList wxMaterialList = new WxMaterialList();
|
|
|
- wxMaterialList.setType("video");
|
|
|
- wxMaterialList.setOffset("0");
|
|
|
- wxMaterialList.setCount("20");
|
|
|
- String result = wxService.getBatchMateria(token,wxMaterialList);
|
|
|
+ String token = wxGzhService.getGzhToken();
|
|
|
+ Map<String,String> param = new HashMap();
|
|
|
+ param.put("appid","wx457ba48e0801c0b6");
|
|
|
+ String result = wxService.clearQuota(token,param);
|
|
|
System.out.println(result);
|
|
|
+ // WxMaterialList wxMaterialList = new WxMaterialList();
|
|
|
+// wxMaterialList.setType("video");
|
|
|
+// wxMaterialList.setOffset("0");
|
|
|
+// wxMaterialList.setCount("20");
|
|
|
+// String result = wxService.getBatchMateria(token,wxMaterialList);
|
|
|
+// System.out.println(result);
|
|
|
// WxMaterial wxMaterial = new WxMaterial();
|
|
|
// wxMaterial.setMedia_id("kD88pyQSlAfJYQIBpBp75Wjs3tWIgKQI6jw--s8kDrZ0AuuQDMyA89LU5CX8UMFY");
|
|
|
// String result2 = wxService.getMateria(token,wxMaterial);
|
|
@@ -43,34 +49,43 @@ public class WxGzhTest {
|
|
|
|
|
|
@Test
|
|
|
public void getWxFreepublish() {
|
|
|
- String token = wxGzhServicee.getGzhToken();
|
|
|
- WxFreepublish wxFreepublish = new WxFreepublish();
|
|
|
- wxFreepublish.setOffset("0");
|
|
|
- wxFreepublish.setCount("20");
|
|
|
- wxFreepublish.setNo_content("1");
|
|
|
- String result = wxService.getFreepublish(token, wxFreepublish);
|
|
|
- JSONObject json = JSONObject.parseObject(result);
|
|
|
- JSONArray jsonArray = json.getJSONArray("item");
|
|
|
-
|
|
|
- for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
- JSONObject jsonB= jsonArray.getJSONObject(i);
|
|
|
- String articleId = jsonB.getString("article_id");
|
|
|
- JSONObject content = jsonB.getJSONObject("content");
|
|
|
- JSONArray newsItem = content.getJSONArray("news_item");
|
|
|
- JSONObject newsItem0 = newsItem.getJSONObject(0);
|
|
|
- String title = newsItem0.getString("title");
|
|
|
- String url = newsItem0.getString("url");
|
|
|
- String thumbUrl = newsItem0.getString("thumb_url");
|
|
|
- String isDeleted = newsItem0.getString("is_deleted");
|
|
|
-
|
|
|
- System.out.println(articleId);
|
|
|
- System.out.println(title);
|
|
|
- System.out.println(url);
|
|
|
- System.out.println(thumbUrl);
|
|
|
- System.out.println(isDeleted);
|
|
|
- }
|
|
|
-
|
|
|
- System.out.println(result);
|
|
|
+ String token = wxGzhService.getGzhToken();
|
|
|
+ int totalCount = 0;
|
|
|
+ int countPerPage = 20;
|
|
|
+
|
|
|
+ // do {
|
|
|
+ WxFreepublish wxFreepublish = new WxFreepublish();
|
|
|
+ wxFreepublish.setOffset(String.valueOf(totalCount));
|
|
|
+ wxFreepublish.setCount(String.valueOf(countPerPage));
|
|
|
+ wxFreepublish.setNo_content("1");
|
|
|
+
|
|
|
+ String result = wxService.getFreepublish(token, wxFreepublish);
|
|
|
+ JSONObject json = JSONObject.parseObject(result);
|
|
|
+ JSONArray jsonArray = json.getJSONArray("item");
|
|
|
+
|
|
|
+ if (jsonArray==null || jsonArray.isEmpty()) {
|
|
|
+ // break;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+ JSONObject jsonB = jsonArray.getJSONObject(i);
|
|
|
+ String articleId = jsonB.getString("article_id");
|
|
|
+ JSONObject content = jsonB.getJSONObject("content");
|
|
|
+ JSONArray newsItem = content.getJSONArray("news_item");
|
|
|
+ JSONObject newsItem0 = newsItem.getJSONObject(0);
|
|
|
+ String title = newsItem0.getString("title");
|
|
|
+ String url = newsItem0.getString("url");
|
|
|
+ String thumbUrl = newsItem0.getString("thumb_url");
|
|
|
+ String isDeleted = newsItem0.getString("is_deleted");
|
|
|
+
|
|
|
+ System.out.println(articleId);
|
|
|
+ System.out.println(title);
|
|
|
+ System.out.println(url);
|
|
|
+ System.out.println(thumbUrl);
|
|
|
+ System.out.println(isDeleted);
|
|
|
+ System.out.println(result);
|
|
|
+ }
|
|
|
+ // } while (true);
|
|
|
|
|
|
|
|
|
}
|