- 积分
- 186
- 金钱
- 165
- 威望
- 0
- 贡献
- 0
- HASS币
- 0
注册会员
- 积分
- 186
- 金钱
- 165
- HASS币
- 0
|
发表于 2023-1-5 23:07:51
|
显示全部楼层
按照您的方法,代码如下:
def SpeakText():
url = "http://192.168.31.28:8123/api/services/xiaomi_miot_raw/speak_text"
Authorization = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI4YWI2NmU1N2YxZDU0ZWQxYjk0MTZhZTBkNjRmNWUzNSIsImlhdCI6MTY3MjkyNjY4MCwiZXhwIjoxOTg4Mjg2NjgwfQ.XFcJ83TcXZfkXmKwWwOQw3LonR_s48KGvsxuM_rEfvg"
sendData = {
"entity_id": "media_player.xiaomi_lx01_2c28_play_control",
"text": "你好",
}
reqHeaders = {
'Authorization': Authorization,
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36'
}
response = requests.post(url, data=sendData,headers=reqHeaders)
#response = requests.get(url, headers=reqHeaders)
page_html = response.content
print(page_html)
可是最后提示:b'{"message":"Data should be valid JSON."}',能否帮忙看下。 |
|