-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
119 additions
and
33 deletions.
There are no files selected for viewing
12 changes: 0 additions & 12 deletions
12
Web Services And Cloud/MovieInfoApp/MovieInfoApp/Class1.cs
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/ActorModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace MovieInfoApp.Models | ||
{ | ||
//using Newtonsoft.Json; | ||
|
||
class ActorModel | ||
{ | ||
//[JsonProperty("id")] | ||
public int Id { get; set; } | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/CreditsModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace MovieInfoApp.Models | ||
{ | ||
//using Newtonsoft.Json; | ||
|
||
class CreditsModel | ||
{ | ||
//[JsonProperty("id")] | ||
public int Id { get; set; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Web Services And Cloud/MovieInfoApp/MovieInfoApp/Models/EpisodeModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace MovieInfoApp.Models | ||
{ | ||
//using Newtonsoft.Json; | ||
|
||
class EpisodeModel | ||
{ | ||
//[JsonProperty("episode_number")] | ||
public int EpisodeNumber { get; set; } | ||
|
||
//[JsonProperty("season")] | ||
public int Season { get; set; } | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
Web Services And Cloud/MovieInfoApp/MovieInfoApp/MovieDb.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
namespace MovieInfoApp | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Net.Http.Headers; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
public class MovieDb | ||
{ | ||
private static readonly Uri BaseUrl = new Uri("https://api.themoviedb.org/3/search/person"); | ||
private const string ApiKey = "xxx"; | ||
|
||
public static void Main() | ||
{ | ||
var client = new HttpClient(); | ||
|
||
var result = GetActorInfoByName(client, "bruce willis"); | ||
|
||
Console.WriteLine(); | ||
} | ||
|
||
private static string GetActorInfoByName(HttpClient client, string name) | ||
{ | ||
string responseData; | ||
var test = Uri.EscapeUriString(name); | ||
string nameQuery = "query=" + Uri.EscapeUriString(name); | ||
UriBuilder targetUrl = new UriBuilder(BaseUrl); | ||
|
||
targetUrl.Query = "api_key=" + ApiKey; | ||
targetUrl.Query = targetUrl.Query.Substring(1) + "&" + nameQuery; | ||
|
||
client.BaseAddress = targetUrl.Uri; | ||
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); | ||
|
||
var response = client.GetAsync("").Result; | ||
responseData = response.Content.ReadAsStringAsync().Result; | ||
|
||
return responseData; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
Web Services And Cloud/MovieInfoApp/MovieInfoApp/UriExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
namespace MovieInfoApp | ||
{ | ||
using System; | ||
using System.Web; | ||
|
||
public static class UriExtensions | ||
{ | ||
public static Uri AddParameter(this Uri url, string paramName, string paramValue) | ||
{ | ||
var uriBuilder = new UriBuilder(url); | ||
var query = HttpUtility.ParseQueryString(uriBuilder.Query); | ||
query[paramName] = paramValue; | ||
uriBuilder.Query = query.ToString(); | ||
|
||
return uriBuilder.Uri; | ||
} | ||
} | ||
} |