Python 使用cloudflare API更改SRV记录

Python 使用cloudflare API更改SRV记录,python,python-3.x,bash,cloudflare,Python,Python 3.x,Bash,Cloudflare,我正在尝试使用cloudflare api自动更新由ngrok反向代理的minecraft服务器的SRV记录。 我现在正在做的是 get_ipython().system_raw(’./ngrok authtoken (authtoken) && ./ngrok tcp 25565 &’) with urllib.request.urlopen(‘http://localhost:4040/api/tunnels’) as response: data = json.lo

我正在尝试使用cloudflare api自动更新由ngrok反向代理的minecraft服务器的SRV记录。 我现在正在做的是

get_ipython().system_raw(’./ngrok authtoken (authtoken) && ./ngrok tcp 25565 &’)
with urllib.request.urlopen(‘http://localhost:4040/api/tunnels’) as response:
data = json.loads(response.read().decode())
(host, port) = data[‘tunnels’][0][‘public_url’][6:].split(’:’)
print(port, host)
subprocess.check_output([‘bash’,‘flare.sh’, port, host])
在flare.sh内部是

-H “X-Auth-Email: *******@********.com”
-H “X-Auth-Key: 00000000000000”
-H “Content-Type: application/json”
–data ‘{“type”: “SRV”, “data”: {“service”: “_minecraft”, “proto”: “_tcp”, “name”: “mc”, “priority”: 1, “weight”: 5, “port”: $1, “target”: “$2”}}'```
然而,这又回来了

{“result”:null,“success”:false,“errors”:[{“code”:9207,“message”:“未能解析请求正文,内容类型必须为application/json”}],“messages”:}

我知道有一种方法可以通过python访问api,但我不知道如何访问(不知道任何编程)。当我运行bash脚本并用正确的端口和目标值替换$1和$2时,它也能正常工作。