我正在尝试使用 C# 从 TheMovieDB API 检索数据。我现在不想使用外部库,因为我想在 C# 中变得更好。
TheMovieDB API 返回给我以下信息:
我有以下课程:
public class raizDoJson
{
public int pagina { get; set; }
public int totalRegistros { get; set; }
public int totalPaginas { get; set; }
public List<serie> series { get; set; }
}
public class serie
{
public string original_name { get; set; }
public int id { get; set; }
public string name { get; set; }
public int vote_count { get; set; }
public double vote_average { get; set; }
public string poster_path { get; set; }
public string first_air_date { get; set; }
public int popularity { get; set; }
public List<generos> genre_ids { get; set; }
public string original_language { get; set; }
public string backdrop_path { get; set; }
public string overview { get; set; }
public List<paises> origin_country { get; set; }
}
public class generos{
public int id { get; set; }
}
public class paises {
public string pais { get; set; }
}
接下来我尝试反序列化它:
public static void lerDados(string query)
{
string api = " API KEY";
string endereco = "http://api.themoviedb.org/3/search/tv?api_key={0}&query={1}";
string url = HttpUtility.UrlDecode(string.Format(endereco, api, query));
Console.WriteLine(url);
Console.ReadKey();
var request = System.Net.WebRequest.Create(url) as System.Net.WebRequest;
request.Method = "GET";
request.ContentLength = 0;
}
}
}
www说
相关分类