package com.fs.ad;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class 积分 {
    public static void main(String[] args) {
        int jf=0;

        for (int i=1; i<=2000; i++) {
            try {
                System.out.println("等待 10 秒...");
               Thread.sleep(10000); // 10000 毫秒 = 10 秒
                System.out.println("等待结束");
            } catch (Exception e) {
                System.out.println("线程被中断。");
            }
            try {
                CloseableHttpClient httpClient = HttpClients.createDefault();
                HttpPost httpPost = new HttpPost("https://userapp.his.cdwjyyh.com//app/integral/addIntegral");

                httpPost.addHeader("AppToken", "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiI0MDQ5MCIsImlhdCI6MTcyOTc2MDExNCwiZXhwIjoxNzYxMjk2MTE0fQ.qTuf4tF7cYh_lHw0L-ydlnFbUGh-0BxLs6ztrpsuO3nvCj49zjsnhFIciVJRqZFP2TZkMrpVmflnIG1O5ZbKXA");
                httpPost.addHeader("Accept-Encoding", "gzip, compress, br, deflate");
                httpPost.addHeader("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.50(0x1800323a) NetType/4G Language/zh_CN");
                httpPost.addHeader("Referer", "https://servicewechat.com/wxc3f0a952b7bc2b94/109/page-frame.html");

                String json = "{\"type\":\"2\"}";
                StringEntity entity = new StringEntity(json);
                httpPost.setEntity(entity);
                httpPost.setHeader("Content-type", "application/json");

                HttpResponse response = httpClient.execute(httpPost);

                if (response.getStatusLine().getStatusCode() == 200) {
                    String responseBody = EntityUtils.toString(response.getEntity());
                    System.out.println(responseBody);
                    jf+=5;
                    System.out.println("预计获得积分:"+jf);
                } else {
                    System.out.println("Request failed");
                }

                httpClient.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }
}
