From ca2d23f534e13357ac9e892483b3d9814d116a7c Mon Sep 17 00:00:00 2001 From: Gerasimos Alexiou Date: Sun, 29 Oct 2017 10:45:41 +0200 Subject: [PATCH] Get Page Information implemented --- src/Net.Facebook.Graph/Models/Page.cs | 51 +++++++++++++++++++++++ src/Net.Facebook.Graph/NetGraphRequest.cs | 15 ++++++- src/Package.nuspec | 10 ++--- 3 files changed, 70 insertions(+), 6 deletions(-) create mode 100644 src/Net.Facebook.Graph/Models/Page.cs diff --git a/src/Net.Facebook.Graph/Models/Page.cs b/src/Net.Facebook.Graph/Models/Page.cs new file mode 100644 index 0000000..e7b6893 --- /dev/null +++ b/src/Net.Facebook.Graph/Models/Page.cs @@ -0,0 +1,51 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace Net.Facebook.Graph.Models +{ + public class Page + { + [JsonProperty("id")] + public string Id { get; set; } + + [JsonProperty("link")] + public string Url { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("about")] + public string Description { get; set; } + + [JsonProperty("category")] + public string Category { get; set; } + public string Address { get; set; } + + [JsonProperty("picture")] + public ProfilePicture Picture { get; set; } + + + public class ProfilePicture + { + [JsonProperty("data")] + public PictureData Data { get; set; } + } + + public class PictureData + { + [JsonProperty("height")] + public int Height { get; set; } + + [JsonProperty("is_silhouette")] + public bool IsSilhouette { get; set; } + + [JsonProperty("url")] + public string Url { get; set; } + + [JsonProperty("width")] + public int Width { get; set; } + } + } +} diff --git a/src/Net.Facebook.Graph/NetGraphRequest.cs b/src/Net.Facebook.Graph/NetGraphRequest.cs index c82ec0a..e78b9c5 100644 --- a/src/Net.Facebook.Graph/NetGraphRequest.cs +++ b/src/Net.Facebook.Graph/NetGraphRequest.cs @@ -9,7 +9,7 @@ namespace Net.Facebook.Graph public static class NetGraphRequest { - public async static Task GetToken(string id, string secret) + public static async Task GetToken(string id, string secret) { try { @@ -34,5 +34,18 @@ public static string CreateTokenUrl(string id, string secret) return url; } + public static async Task GetPageInfo(string url) + { + try + { + var client = new HttpClient(); + var response = await client.GetAsync(url); + var result = await response.Content.ReadAsStringAsync(); + return JsonConvert.DeserializeObject(result); + } + + catch (Exception) { return null; } + } + } } diff --git a/src/Package.nuspec b/src/Package.nuspec index 777e58d..0ab90c6 100644 --- a/src/Package.nuspec +++ b/src/Package.nuspec @@ -2,7 +2,7 @@ Net.Facebook.Graph - 1.0.5 + 1.0.7 GeralexGR GeralexGR https://github.com/jerrak0s/Net.Facebook.Graph/blob/master/LICENSE @@ -23,20 +23,20 @@ - + - + - + - +