iDirect IQ200 REST API
################################ ###### HTTP 基本认证方式 ( 命令行参数中直接输入用户名和密码 ) 获取 Modem LED 状态信息
### 请求命令 curl -u admin:P@55w0rd! -isk 'https://172.28.170.217/api/1.0/terminal/device/led' # 响应头数据 HTTP/1.1 200 OK Connection: close Content-Type: application/json Content-Length: 509 # 响应体数据 { "data": [ { "id": 0, "name": "rx", "color": "yellow", "flash": "", "url": "/api/1.0/terminal/device/led/0" }, { "id": 2, "name": "tx", "color": "yellow", "flash": "", "url": "/api/1.0/terminal/device/led/2" }, { "id": 3, "name": "net", "color": "yellow", "flash": "0.5/0.5", "url": "/api/1.0/terminal/device/led/3" }, { "id": 4, "name": "power", "color": "green", "flash": "", "url": "/api/1.0/terminal/device/led/4" }, { "id": 5, "name": "status", "color": "green", "flash": "", "url": "/api/1.0/terminal/device/led/5" } ], "meta": { "url": "/api/1.0/terminal/device/led" } } ################################ ###### HTTP 基本认证方式 ( HTTP请求头中添加编码后的用户名和密码 ) 获取 Modem LED 状态信息
### 请求命令 curl -isk 'https://172.28.170.217/api/1.0/terminal/device/led' -H 'Authorization: Basic YWRtaW46UEA1NXcwcmQh' # 响应头数据 HTTP/1.1 200 OK Connection: close Content-Type: application/json Content-Length: 509 # 响应体数据 { "data": [ { "id": 0, "name": "rx", "color": "yellow", "flash": "", "url": "/api/1.0/terminal/device/led/0" }, { "id": 2, "name": "tx", "color": "yellow", "flash": "", "url": "/api/1.0/terminal/device/led/2" }, { "id": 3, "name": "net", "color": "yellow", "flash": "0.5/0.5", "url": "/api/1.0/terminal/device/led/3" }, { "id": 4, "name": "power", "color": "green", "flash": "", "url": "/api/1.0/terminal/device/led/4" }, { "id": 5, "name": "status", "color": "green", "flash": "", "url": "/api/1.0/terminal/device/led/5" } ], "meta": { "url": "/api/1.0/terminal/device/led" } } ################################
################################ ###### Session Cookie 认证方式 ( HTTP请求头中Cookie添加session ) ### 请求命令 ( 获取 csrf_token ) curl -isk 'https://172.28.170.217/' # 响应头数据 HTTP/1.1 302 Found Set-Cookie: csrf_token=D5nuvGEcWxZnwXorSuHeXk0FVN1Zgng6m9yenRQZ9aI; SameSite; secure Location: /login.html Connection: close Content-Length: 0 -------------------------------- ### 请求命令 ( 获取 session ) curl -isk 'https://172.28.170.217/authorize?success=&fail=' -H 'Cookie: csrf_token=D5nuvGEcWxZnwXorSuHeXk0FVN1Zgng6m9yenRQZ9aI' -d $'user=admin&password=P@55w0rd\u0021&csrf_token=D5nuvGEcWxZnwXorSuHeXk0FVN1Zgng6m9yenRQZ9aI' # 响应头数据 HTTP/1.1 200 OK Set-Cookie: session=ca3bf7d95e86c149b404f3f29e34b4e6; http-only; secure Connection: close Content-Length: 5 -------------------------------- ### 请求命令 ( 获取 Modem LED 状态信息 ) curl -isk 'https://172.28.170.217/api/1.0/terminal/device/led' -H 'Cookie: csrf_token=D5nuvGEcWxZnwXorSuHeXk0FVN1Zgng6m9yenRQZ9aI; session=ca3bf7d95e86c149b404f3f29e34b4e6' # 响应头数据 HTTP/1.1 200 OK Connection: close Content-Type: application/json Content-Length: 509 # 响应体数据 { "data": [ { "id": 0, "name": "rx", "color": "yellow", "flash": "", "url": "/api/1.0/terminal/device/led/0" }, { "id": 2, "name": "tx", "color": "yellow", "flash": "", "url": "/api/1.0/terminal/device/led/2" }, { "id": 3, "name": "net", "color": "yellow", "flash": "0.5/0.5", "url": "/api/1.0/terminal/device/led/3" }, { "id": 4, "name": "power", "color": "green", "flash": "", "url": "/api/1.0/terminal/device/led/4" }, { "id": 5, "name": "status", "color": "green", "flash": "", "url": "/api/1.0/terminal/device/led/5" } ], "meta": { "url": "/api/1.0/terminal/device/led" } } -------------------------------- ### 请求命令 ( 获取 session ) curl curl -isk 'https://172.28.170.217/authorize?logout' -H 'Cookie: csrf_token=D5nuvGEcWxZnwXorSuHeXk0FVN1Zgng6m9yenRQZ9aI; session=ca3bf7d95e86c149b404f3f29e34b4e6' # 响应头数据 HTTP/1.1 302 Found Set-Cookie: session=; Max-Age=0; secure Set-Cookie: csrf_token=YEd0k7LcWd6cbC5XPoy39TBrmuPXjvuEh6bEZQF98mE; SameSite; secure Location: /login.html Connection: close Content-Length: 0 ################################
============= End
标签:led,api,REST,terminal,url,API,device,iDirect,1.0 From: https://www.cnblogs.com/lsgxeva/p/18462246