Riot http api调用.NET MVC

时间:2016-06-26 15:07:51

标签: c# asp.net-mvc model-view-controller json.net riot-games-api

        WebClient client = new WebClient();
        string json_response = client.DownloadString("https://tr.api.pvp.net/api/lol/tr/v1.4/summoner/by-name/SUMMONERNAME?api_key=KEY");
        dynamic deserialized_response = JsonConvert.DeserializeObject<dynamic>(json_response);
        string Summonerid = deserialized_response.id;

你好,我试着只打电话给我,但我失败了。我也尝试用viewmodel做这个,但我仍然失败了。而且我还想制作一个变量SUMMONERNAME,我怎么能有一个文本框输入到SUMMONERNAME。 这是api的参考链接“https://developer.riotgames.com/api/methods#!/1079/3722

        string json_response = client.DownloadString("https://tr.api.pvp.net/api/lol/tr/v1.4/summoner/by-name/SUMMONERNAME?api_key=KEY");
        RiotApiViewModel deserialized_response = JsonConvert.DeserializeObject<RiotApiViewModel>(json_response);
        long id = deserialized_response.id;

1 个答案:

答案 0 :(得分:0)

var foundSummoner = JsonConvert.DeserializeObject&gt;(json_response); 这解决了我的错误