我可以获取到accessToken,
官方API文档https://open.ys7.com/doc/zh/book/index/device_option.html
比如在调用c6h的预置位1,为什么会出现下附带的301页面被重定位的地址,https://open.ys7.com/api/lapp/device/preset/move,不是对这个地址请求吗, 或者查询其他的功能,都会出现301网页被重定向,求原因分析。 我用的语言是python34
我现在每次调各个功能,都是返回如下的重定向错误
301 Moved Permanently
The requested resource has been assigned a new permanent URI.
python3.4 代码如下:
def devices_list():#调用预置位
global accessToken
#accessToken='at.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
test_data1 = { 'accessToken':accessToken,'deviceSerial':'XXXXXX','channelNo':1,'index':1}
test_data_urlencode1=urllib.parse.urlencode(test_data1).encode('utf-8')
print(test_data_urlencode1)
requrl1='https://open.ys7.com/api/lapp/device/preset/move'#请求调用预置位的地址
headerdata1={
'Content-type': 'application/x-www-form-urlencoded',
'Host':'open.ys7.com'
}
conn1=http.client.HTTPConnection("open.ys7.com")
conn1.request("POST",url=requrl1,body=test_data_urlencode1,headers=headerdata1)
response1=conn1.getresponse()
print(response1.status)
print(response1.reason)
jump=response1.headers['Location']
print(jump)
res2=response1.read().decode('utf-8')
print(res2)
devices_list()