如何在没有预共享密钥的情况下通过Sony Bravia TV IP控制进行身份验证

问题描述 投票:3回答:1

本指南(https://pro-bravia.sony.net/develop/integrate/ip-control/)描述了如何使用IP控制API,方法是在电视菜单中设置预共享密钥,然后将此密钥和请求的标题一起发送给X-Auth-PSK: [Pre-Shared Key]

除我以外的其他应用程序在网络上发现了我的电视,电视上弹出了(一次)图钉,然后由客户端的用户输入(例如远程应用程序)。此身份验证流程如何工作?我如何自己实施?

api authentication sony
1个回答
0
投票

您可以通过执行以下代码来调用身份验证,首先在浏览器中打开一个标签,然后输入电视的IP地址,这样,当您通过控制台执行此代码时,不会收到CORS错误。

var tvIPAddress = '192.168.0.16'; // the IP of the TV
var id = 1001; // random integer number ( that will be assigned to your control device )

var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://'+tvIPAddress+'/sony/accessControl');
xhr.send(JSON.stringify(
{method: "actRegister",
  version: "1.0",
  id: id,
  params: [{ clientid: "DEVICE NAME: RANDOM-CLIENT-ID-XXXXXXXXXX" , nickname: "YOUR-DEVICE-NAME" },[{function:"WOL",value:"no"}]]
  }
));

然后在弹出窗口中输入电视的PIN码作为密码。将用户名字段留空。

然后您可以像这样发送IRCC命令:

var code = "AAAAAQAAAAEAAAASAw=="; // volume up

xhr.open('POST', 'http://192.168.0.16/sony/IRCC');
xhr.setRequestHeader('SOAPACTION', "urn:schemas-sony-com:service:IRCC:1#X_SendIRCC");
xhr.send('<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:X_SendIRCC xmlns:u="urn:schemas-sony-com:service:IRCC:1"><IRCCCode>'+code+'</IRCCCode></u:X_SendIRCC></s:Body></s:Envelope>');

您可以在这里找到更多信息:https://pro-bravia.sony.net/develop/integrate/ircc-ip/overview/index.html

© www.soinside.com 2019 - 2024. All rights reserved.