【问题标题】:LoL Live API Usage英雄联盟直播 API 使用
【发布时间】:2020-12-21 04:29:38
【问题描述】:

我一直在尝试弄清楚如何使用英雄联盟实时 API。我已经成功使用了这样的端点:/lol/summoner/v4/summoners/by-name/{summonerName}

但是当谈到使用这样的端点时(用于实时游戏数据):GET https://127.0.0.1:2999/liveclientdata/allgamedata

我得到了错误 “无法连接到目标主机”

这是我一直在尝试的示例代码:

private IEnumerator Test()
    {
        string url = "https://127.0.0.1:2999/liveclientdata/activeplayername";

        using (UnityWebRequest webRequest = UnityWebRequest.Get(url))
        {
            yield return webRequest.SendWebRequest();

            string error = webRequest.error;

            if (error != null)
            {
                Debug.LogError("[LoLAPI] - " + error);
            }
            else
            {
                Debug.Log(webRequest.downloadHandler.text);
            }
        }
    }

我错过了什么吗?

谢谢

【问题讨论】:

  • 网址看起来不错,您是在代理后面还是想知道什么?
  • 不,只是普通的互联网连接
  • 它正在连接到你的机器,所以你需要检查它是否正在运行并监听 thar 端口
  • 如何检查端口是否正在运行?鉴于这是 LOL 正在使用的端口,它不应该一直使用该端口吗?

标签: c# api http unity3d


【解决方案1】:

UnityWebRequest 的实现默认不接受自签名 SSL 证书。尝试添加:

public class UncheckedCertificateHandler: CertificateHandler
{
    protected override bool ValidateCertificate(byte[] certData)
    {
        // certificate validation always returns true
        return true;
    }
} 

然后当你创建网络请求时:

using (UnityWebRequest webRequest = UnityWebRequest.Get(url))
{
    www.certificateHandler = new UncheckedCertificateHandler();
    yield return webRequest.SendWebRequest();

或者,如果可用,只需使用http://

【讨论】:

  • 感谢您的回复。我也试过了,没有新的信息可以分享。不幸的是,同样的错误。
猜你喜欢
  • 2021-07-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多