const fetch = require('node-fetch'); // Node.js 18以下版本需要安装 node-fetch
const tools = require('../../../tools');
const config  = require('../../../etc/config.json');
const redis_help = require('../../use_redis');
const helper = require('../../helper');
const CMD = {}

CMD.get_zh_call_back_template = async function() {
    try{
        let timestamp = helper.getCurrentUnixTimestamp()
        let url = `https://ecom.zhihu.com/api/km-agent/callback-rules?offset=0&limit=20`
        const response =   await fetch(url, {
            "headers": {
                "accept": "application/json, text/plain, */*",
                "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
                "priority": "u=1, i",
                "sec-ch-ua": "\"Not(A:Brand\";v=\"99\", \"Microsoft Edge\";v=\"133\", \"Chromium\";v=\"133\"",
                "sec-ch-ua-mobile": "?0",
                "sec-ch-ua-platform": "\"Windows\"",
                "sec-fetch-dest": "empty",
                "sec-fetch-mode": "cors",
                "sec-fetch-site": "same-origin",
                "x-requested-with": "XMLHttpRequest",
                "cookie": "_xsrf=7bCsoKjmfrIE0D36ajUc9s6CM9OxdPHQ; _zap=aa0b20fb-9951-4f27-9f66-dafff809f1a9; d_c0=ADASSwlwjxmPTrW0768vZ0BKygxzh_LFDDI=|1731902666; __zse_ck=004_hDt/N6kJqB2LjbDPVi1aeHkPAJ3D9i0XH1OtWnDkJmeiOQerdhuEbZ7dE7LoCSKq93LfwfCm76sfwzVzS1KLr=3ysQ/G7PdXsGsTgfiXvwpaBdKuV8K4A2Q7hwuIbMxC-BsdYkcUoqCnI0s8QnvTGFO/DzhuqvMnZKGYCg8jcpLXqMyAJKrwjqGNnSQLDZXttYF+4VvXX+eGFPaVbxoRWYhzQ86gtapCiGeU+o6g4bqdj0i/CnoJVmn67lMHZoDUB; BEC=684e706569bf16169217bb2a788786f3; Hm_lvt_98beee57fd2ef70ccdd5ca52b9740c49=1739763111,1741447186; Hm_lpvt_98beee57fd2ef70ccdd5ca52b9740c49=1741447186; HMACCOUNT=8B23C823A8286BDF; captcha_session_v2=2|1:0|10:1741447186|18:captcha_session_v2|88:bjAvUkJMR1pmaENoaU9lNmNQUHI4VUVOcmNlV29DOUdhc2paN3k4NXgzR1dDbTZZS2hlSE9oT0NHbE9Wd1RHbg==|2c30267bc15ea23a591951d569b02a5866c6fe4153bfe9844e03238e35bb08f1; captcha_ticket_v2=2|1:0|10:1741447199|17:captcha_ticket_v2|728:eyJ2YWxpZGF0ZSI6IkNOMzFfdHgzRlhadC5pRzFLUjhCdTRILlVieUtfKmE4THJTZExjRG5zR0RQQ3piczJOZm1UeFhOWlVlWmVZRSpweGZ0ckhhSGdJUkF2ZVBWVDNVVXdlNk5VdGdaRWswLmlOVHRfZXlMX1BJYjl5YmQ0aVNUU3gxY09lT0FIbXZrRU5jd3RVc1MyWHpiQXo1dGRGX1NUa21Tc0tHYjEuaFFmRHBkMFJtdUNRKjJxMzUucVNZMkRQdktoM2N0c3hlR0syVW1FZ1ltUEVQWF9XR2JxSE5LekRHa2NxdzRua1lkVURPSVBod1g0TktuZFBOcV9mZkVydGxQMUIyYlkyLk5PT1oxRjN3LlhhTTlUUWx3T1QzQ3A4WkswcypsdDljXzNPOVh0S2o0QnFTNkhtM2ZMMjY1MTF6ZUVfeEw4Sm1YX2Y4ZEprQ29vUjVqdnpWZ0xfVjNaSVJQYWJCYnRJU2FhcFBVKlVJZWFPS3FGaVJMKjJBdipXb1dGd3BQUkZWSnNreTZWU0Z2QWttUzAqSGNobFJMVTlIaml2Um9ZZDUweklHclppclM1bGxDYV9lTWpCa2RCUk50TFNlbzEyeU81OXRMY2lYYUhKOHlVUFRuM09Mem1LRjl4RS4yY1RUd1Y5eFp2OVllKnZFMFdEVGNLeEZIRzAya1J5TnRrTUptMExYQ1N3WkduNGc3N192X2lfMSJ9|d385252c1df14a29550fa1bd5e7c0ea7188926820724b891b1e45b4a7957e487; z_c0=2|1:0|10:1741447200|4:z_c0|92:Mi4xN1lrbldnQUFBQUFBTUJKTENYQ1BHU1lBQUFCZ0FsVk5JSzY1YUFDY1RrZmZuVXJRTXVQYWplQ1ZiRkVTNUZXUXp3|16df962e9951eafd96b5a7b6405bbbec0154b787755fed1df9f4ebc6e206dd21; ecom_merchant=1857114769787609088",
                "Referer": "https://ecom.zhihu.com/vip-apps/out-distribution/contentLib/list",
                "Referrer-Policy": "no-referrer-when-downgrade"
            },
            "body": null,
            "method": "GET"
          });
    
          const data =  await response.json();
          if(data.data!=undefined&&data.data.length<=0){
            throw data
        }
          console.log('get_zh_call_back_template::响应状态:', response.status);
          console.log('get_zh_call_back_template::响应数据:', data);
          return data.data;
    }catch(error){
        console.error('get_zh_call_back_template::请求错误:', error);
        return null;
    }

}

module.exports = CMD;