diff --git a/src/BirdsiteLive.Common/BirdsiteLive.Common.csproj b/src/BirdsiteLive.Common/BirdsiteLive.Common.csproj
new file mode 100644
index 0000000..9f5c4f4
--- /dev/null
+++ b/src/BirdsiteLive.Common/BirdsiteLive.Common.csproj
@@ -0,0 +1,7 @@
+
+
+
+ netstandard2.0
+
+
+
diff --git a/src/BirdsiteLive.Common/Settings/TwitterSettings.cs b/src/BirdsiteLive.Common/Settings/TwitterSettings.cs
new file mode 100644
index 0000000..d0970f2
--- /dev/null
+++ b/src/BirdsiteLive.Common/Settings/TwitterSettings.cs
@@ -0,0 +1,10 @@
+namespace BirdsiteLive.Common.Settings
+{
+ public class TwitterSettings
+ {
+ public string ConsumerKey { get; set; }
+ public string ConsumerSecret { get; set; }
+ public string AccessToken { get; set; }
+ public string AccessTokenSecret { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/BirdsiteLive.Twitter/BirdsiteLive.Twitter.csproj b/src/BirdsiteLive.Twitter/BirdsiteLive.Twitter.csproj
index 84e0bf0..8b73ab8 100644
--- a/src/BirdsiteLive.Twitter/BirdsiteLive.Twitter.csproj
+++ b/src/BirdsiteLive.Twitter/BirdsiteLive.Twitter.csproj
@@ -8,4 +8,8 @@
+
+
+
+
diff --git a/src/BirdsiteLive.Twitter/Models/TwitterUser.cs b/src/BirdsiteLive.Twitter/Models/TwitterUser.cs
new file mode 100644
index 0000000..82988a3
--- /dev/null
+++ b/src/BirdsiteLive.Twitter/Models/TwitterUser.cs
@@ -0,0 +1,11 @@
+namespace BirdsiteLive.Twitter.Models
+{
+ public class TwitterUser
+ {
+ public string Name { get; set; }
+ public string Description { get; set; }
+ public string Url { get; set; }
+ public string ProfileImageUrl { get; set; }
+ public string ProfileBackgroundImageUrl { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/src/BirdsiteLive.Twitter/Settings/TwitterSettings.cs b/src/BirdsiteLive.Twitter/Settings/TwitterSettings.cs
deleted file mode 100644
index 024a6de..0000000
--- a/src/BirdsiteLive.Twitter/Settings/TwitterSettings.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-namespace BirdsiteLive.Twitter.Settings
-{
- public class TwitterSettings
- {
- #region Ctor
- public TwitterSettings(string apiKey, string consumerKey, string consumerSecret, string accessToken, string accessTokenSecret)
- {
- ConsumerKey = consumerKey;
- ConsumerSecret = consumerSecret;
- AccessToken = accessToken;
- AccessTokenSecret = accessTokenSecret;
- }
- #endregion
-
- public string ConsumerKey { get; set; }
- public string ConsumerSecret { get; set; }
- public string AccessToken { get; set; }
- public string AccessTokenSecret { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/BirdsiteLive.Twitter/TwitterService.cs b/src/BirdsiteLive.Twitter/TwitterService.cs
index 261a9b3..0a6a533 100644
--- a/src/BirdsiteLive.Twitter/TwitterService.cs
+++ b/src/BirdsiteLive.Twitter/TwitterService.cs
@@ -1,11 +1,14 @@
using System;
-using BirdsiteLive.Twitter.Settings;
+using System.Threading.Tasks;
+using BirdsiteLive.Common.Settings;
+using BirdsiteLive.Twitter.Models;
using Tweetinvi;
namespace BirdsiteLive.Twitter
{
public interface ITwitterService
{
+ TwitterUser GetUser(string username);
}
public class TwitterService : ITwitterService
@@ -19,9 +22,19 @@ namespace BirdsiteLive.Twitter
}
#endregion
- public void GetUser(string username)
+ public TwitterUser GetUser(string username)
{
+ Auth.SetUserCredentials(_settings.ConsumerKey, _settings.ConsumerSecret, _settings.AccessToken, _settings.AccessTokenSecret);
var user = User.GetUserFromScreenName(username);
+
+ return new TwitterUser
+ {
+ Name = user.Name,
+ Description = user.Description,
+ Url = user.Url,
+ ProfileImageUrl = user.ProfileImageUrl,
+ ProfileBackgroundImageUrl = user.ProfileBackgroundImageUrl
+ };
}
}
}
diff --git a/src/BirdsiteLive.sln b/src/BirdsiteLive.sln
index d6a9101..0efc944 100644
--- a/src/BirdsiteLive.sln
+++ b/src/BirdsiteLive.sln
@@ -5,11 +5,13 @@ VisualStudioVersion = 16.0.29911.84
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BirdsiteLive", "BirdsiteLive\BirdsiteLive.csproj", "{4059D92B-A86B-4765-A905-EFC2D7259C34}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BirdsiteLive.Cryptography", "BirdsiteLive.Cryptography\BirdsiteLive.Cryptography.csproj", "{160AD138-4E29-4706-8546-9826B529E9B2}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BirdsiteLive.Cryptography", "BirdsiteLive.Cryptography\BirdsiteLive.Cryptography.csproj", "{160AD138-4E29-4706-8546-9826B529E9B2}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{4FEAD6BC-3C8E-451A-8CA1-FF1AF47D26CC}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BirdsiteLive.Twitter", "BirdsiteLive.Twitter\BirdsiteLive.Twitter.csproj", "{77C559D1-80A2-4B1C-A566-AE2D156944A4}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BirdsiteLive.Twitter", "BirdsiteLive.Twitter\BirdsiteLive.Twitter.csproj", "{77C559D1-80A2-4B1C-A566-AE2D156944A4}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BirdsiteLive.Common", "BirdsiteLive.Common\BirdsiteLive.Common.csproj", "{E64E7501-5DB8-4620-BA35-BA59FD746ABA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -29,6 +31,10 @@ Global
{77C559D1-80A2-4B1C-A566-AE2D156944A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{77C559D1-80A2-4B1C-A566-AE2D156944A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{77C559D1-80A2-4B1C-A566-AE2D156944A4}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E64E7501-5DB8-4620-BA35-BA59FD746ABA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E64E7501-5DB8-4620-BA35-BA59FD746ABA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E64E7501-5DB8-4620-BA35-BA59FD746ABA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E64E7501-5DB8-4620-BA35-BA59FD746ABA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -36,6 +42,7 @@ Global
GlobalSection(NestedProjects) = preSolution
{160AD138-4E29-4706-8546-9826B529E9B2} = {4FEAD6BC-3C8E-451A-8CA1-FF1AF47D26CC}
{77C559D1-80A2-4B1C-A566-AE2D156944A4} = {4FEAD6BC-3C8E-451A-8CA1-FF1AF47D26CC}
+ {E64E7501-5DB8-4620-BA35-BA59FD746ABA} = {4FEAD6BC-3C8E-451A-8CA1-FF1AF47D26CC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {69E8DCAD-4C37-4010-858F-5F94E6FBABCE}
diff --git a/src/BirdsiteLive/BirdsiteLive.csproj b/src/BirdsiteLive/BirdsiteLive.csproj
index 64c23e5..ca145a6 100644
--- a/src/BirdsiteLive/BirdsiteLive.csproj
+++ b/src/BirdsiteLive/BirdsiteLive.csproj
@@ -13,6 +13,7 @@
+
diff --git a/src/BirdsiteLive/Controllers/UserController.cs b/src/BirdsiteLive/Controllers/UserController.cs
index 776f1a9..bd6c440 100644
--- a/src/BirdsiteLive/Controllers/UserController.cs
+++ b/src/BirdsiteLive/Controllers/UserController.cs
@@ -3,22 +3,34 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using BirdsiteLive.Twitter;
using Microsoft.AspNetCore.Mvc;
namespace BirdsiteLive.Controllers
{
public class UserController : Controller
{
+ private readonly ITwitterService _twitterService;
+
+ #region Ctor
+ public UserController(ITwitterService twitterService)
+ {
+ _twitterService = twitterService;
+ }
+ #endregion
+
[Route("/@{id}")]
[Route("/user/{id}")]
public IActionResult Index(string id)
{
+ var user = _twitterService.GetUser(id);
+
var r = Request.Headers["Accept"].First();
- if(r.Contains("application/activity+json"))
+ if (r.Contains("application/activity+json"))
return Json(new { test = "test" });
-
- return View();
+
+ return View(user);
}
}
}
\ No newline at end of file
diff --git a/src/BirdsiteLive/Startup.cs b/src/BirdsiteLive/Startup.cs
index b63cb07..b696d03 100644
--- a/src/BirdsiteLive/Startup.cs
+++ b/src/BirdsiteLive/Startup.cs
@@ -2,8 +2,8 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
+using BirdsiteLive.Common.Settings;
using BirdsiteLive.Models;
-using BirdsiteLive.Twitter.Settings;
using Lamar;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
@@ -43,12 +43,7 @@ namespace BirdsiteLive
public void ConfigureContainer(ServiceRegistry services)
{
var twitterSettings = Configuration.GetSection("Twitter").Get();
-
- services.For().Use()
- .Ctor("accessToken").Is(twitterSettings.AccessToken)
- .Ctor("accessTokenSecret").Is(twitterSettings.AccessTokenSecret)
- .Ctor("consumerKey").Is(twitterSettings.ConsumerKey)
- .Ctor("consumerSecret").Is(twitterSettings.ConsumerSecret);
+ services.For().Use(x => twitterSettings);
services.Scan(_ =>
{
diff --git a/src/BirdsiteLive/Views/User/Index.cshtml b/src/BirdsiteLive/Views/User/Index.cshtml
index edbda91..8c3dd2f 100644
--- a/src/BirdsiteLive/Views/User/Index.cshtml
+++ b/src/BirdsiteLive/Views/User/Index.cshtml
@@ -5,3 +5,6 @@
User
+@ViewData.Model.Name
+
+@ViewData.Model.Description