diff --git a/InstaSharper.Examples/Basics.cs b/InstaSharper.Examples/Basics.cs
deleted file mode 100644
index 82e39647..00000000
--- a/InstaSharper.Examples/Basics.cs
+++ /dev/null
@@ -1,90 +0,0 @@
-using System;
-using System.Linq;
-using InstaSharper.API;
-using InstaSharper.API.Builder;
-using InstaSharper.Classes;
-using InstaSharper.Classes.Models;
-using InstaSharper.Examples.Utils;
-
-namespace InstaSharper.Examples
-{
- internal class Basics
- {
- ///
- /// Api instance (one instance per Instagram user)
- ///
- private static IInstaApi _instaApi;
-
- ///
- /// Config values
- ///
- private static int _maxDescriptionLength = 20;
-
-
- private static void Main(string[] args)
- {
- // create user session data and provide login details
- var userSession = new UserSessionData
- {
- UserName = "username",
- Password = "password"
- };
- // create new InstaApi instance using Builder
- _instaApi = new InstaApiBuilder()
- .SetUser(userSession)
- .Build();
- // login
- var logInResult = _instaApi.Login();
- if (!logInResult.Succeeded) { Console.WriteLine($"Unable to login: {logInResult.Info.Message}"); }
- else
- {
- // get currently logged in user
- var currentUser = _instaApi.GetCurrentUser().Value;
- Console.WriteLine($"Logged in: username - {currentUser.UserName}, full name - {currentUser.FullName}");
-
- // get self followers
- var followers = _instaApi.GetUserFollowersAsync(currentUser.UserName, 5).Result.Value;
- Console.WriteLine($"Count of followers [{currentUser.UserName}]:{followers.Count}");
-
- // get self user's media, latest 5 pages
- var currentUserMedia = _instaApi.GetUserMedia(currentUser.UserName, 5);
- if (currentUserMedia.Succeeded)
- {
- Console.WriteLine($"Media count [{currentUser.UserName}]: {currentUserMedia.Value.Count}");
- foreach (var media in currentUserMedia.Value) PrintMedia("Self media", media);
- }
-
- //get user time line feed, latest 5 pages
- var userFeed = _instaApi.GetUserTimelineFeed(5);
- if (userFeed.Succeeded)
- {
- Console.WriteLine($"Feed items (in {userFeed.Value.Pages} pages) [{currentUser.UserName}]: {userFeed.Value.Medias.Count}");
- foreach (var media in userFeed.Value.Medias) PrintMedia("Feed media", media);
- //like first 10 medias from user timeline feed
- foreach (var media in userFeed.Value.Medias.Take(10))
- {
- var likeResult = _instaApi.LikeMedia(media.InstaIdentifier);
- var resultString = likeResult.Value ? "liked" : "not like";
- Console.WriteLine($"Media {media.Code} {resultString}");
- }
- }
-
- // get tag feed, latest 5 pages
- var tagFeed = _instaApi.GetTagFeed("quadcopter", 5);
- if (tagFeed.Succeeded)
- {
- Console.WriteLine($"Tag feed items (in {tagFeed.Value.Pages} pages) [{currentUser.UserName}]: {tagFeed.Value.Medias.Count}");
- foreach (var media in tagFeed.Value.Medias) PrintMedia("Tag feed", media);
- }
- var logoutResult = _instaApi.Logout();
- if (logoutResult.Value) Console.WriteLine("Logout succeed");
- }
- Console.ReadKey();
- }
-
- private static void PrintMedia(string header, InstaMedia media)
- {
- Console.WriteLine($"{header} [{media.User.UserName}]: {media.Caption?.Text.Truncate(_maxDescriptionLength)}, {media.Code}, likes: {media.LikesCount}, multipost: {media.IsMultiPost}");
- }
- }
-}
\ No newline at end of file
diff --git a/InstaSharper.Examples/InstaSharper.Examples.csproj b/InstaSharper.Examples/InstaSharper.Examples.csproj
index e1ae411e..d6720a57 100644
--- a/InstaSharper.Examples/InstaSharper.Examples.csproj
+++ b/InstaSharper.Examples/InstaSharper.Examples.csproj
@@ -46,8 +46,12 @@
-
+
+
+
+
+
diff --git a/InstaSharper.Examples/Program.cs b/InstaSharper.Examples/Program.cs
new file mode 100644
index 00000000..3e4530a2
--- /dev/null
+++ b/InstaSharper.Examples/Program.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using InstaSharper.API;
+using InstaSharper.API.Builder;
+using InstaSharper.Classes;
+using InstaSharper.Examples.Samples;
+
+namespace InstaSharper.Examples
+{
+ public class Program
+ {
+ ///
+ /// Api instance (one instance per Instagram user)
+ ///
+ private static IInstaApi _instaApi;
+
+ private static void Main(string[] args)
+ {
+ Console.WriteLine("Starting demo of InstaSharper project");
+ // create user session data and provide login details
+ var userSession = new UserSessionData
+ {
+ UserName = "username",
+ Password = "password"
+ };
+ // create new InstaApi instance using Builder
+ _instaApi = new InstaApiBuilder()
+ .SetUser(userSession)
+ .Build();
+ // login
+ var logInResult = _instaApi.Login();
+ if (!logInResult.Succeeded)
+ {
+ Console.WriteLine($"Unable to login: {logInResult.Info.Message}");
+ }
+ else
+ {
+ Console.WriteLine("Press 1 to start basic demo samples");
+ Console.WriteLine("Press 2 to start upload photo demo sample");
+ Console.WriteLine("Press 3 to start comment media demo sample");
+
+ var key = Console.ReadKey();
+ switch (key.Key)
+ {
+ case ConsoleKey.D1:
+ new Basics(_instaApi).DoShow();
+ break;
+ case ConsoleKey.D2:
+ new UploadPhoto(_instaApi).DoShow();
+ break;
+ case ConsoleKey.D3:
+ new CommentMedia(_instaApi).DoShow();
+ break;
+ default:
+ break;
+ }
+ var logoutResult = _instaApi.Logout();
+ if (logoutResult.Value) Console.WriteLine("Logout succeed");
+ }
+ Console.ReadKey();
+ }
+ }
+}
\ No newline at end of file
diff --git a/InstaSharper.Examples/Samples/Basics.cs b/InstaSharper.Examples/Samples/Basics.cs
new file mode 100644
index 00000000..f933dd71
--- /dev/null
+++ b/InstaSharper.Examples/Samples/Basics.cs
@@ -0,0 +1,69 @@
+using System;
+using System.Linq;
+using InstaSharper.API;
+using InstaSharper.Examples.Utils;
+
+namespace InstaSharper.Examples.Samples
+{
+ internal class Basics
+ {
+ ///
+ /// Config values
+ ///
+ private static readonly int _maxDescriptionLength = 20;
+
+ private readonly IInstaApi _instaApi;
+
+ public Basics(IInstaApi instaApi)
+ {
+ _instaApi = instaApi;
+ }
+
+ public void DoShow()
+ {
+ // get currently logged in user
+ var currentUser = _instaApi.GetCurrentUser().Value;
+ Console.WriteLine($"Logged in: username - {currentUser.UserName}, full name - {currentUser.FullName}");
+
+ // get self followers
+ var followers = _instaApi.GetUserFollowersAsync(currentUser.UserName, 5).Result.Value;
+ Console.WriteLine($"Count of followers [{currentUser.UserName}]:{followers.Count}");
+
+ // get self user's media, latest 5 pages
+ var currentUserMedia = _instaApi.GetUserMedia(currentUser.UserName, 5);
+ if (currentUserMedia.Succeeded)
+ {
+ Console.WriteLine($"Media count [{currentUser.UserName}]: {currentUserMedia.Value.Count}");
+ foreach (var media in currentUserMedia.Value)
+ ConsoleUtils.PrintMedia("Self media", media, _maxDescriptionLength);
+ }
+
+ //get user time line feed, latest 5 pages
+ var userFeed = _instaApi.GetUserTimelineFeed(5);
+ if (userFeed.Succeeded)
+ {
+ Console.WriteLine(
+ $"Feed items (in {userFeed.Value.Pages} pages) [{currentUser.UserName}]: {userFeed.Value.Medias.Count}");
+ foreach (var media in userFeed.Value.Medias)
+ ConsoleUtils.PrintMedia("Feed media", media, _maxDescriptionLength);
+ //like first 10 medias from user timeline feed
+ foreach (var media in userFeed.Value.Medias.Take(10))
+ {
+ var likeResult = _instaApi.LikeMedia(media.InstaIdentifier);
+ var resultString = likeResult.Value ? "liked" : "not liked";
+ Console.WriteLine($"Media {media.Code} {resultString}");
+ }
+ }
+
+ // get tag feed, latest 5 pages
+ var tagFeed = _instaApi.GetTagFeed("quadcopter", 5);
+ if (tagFeed.Succeeded)
+ {
+ Console.WriteLine(
+ $"Tag feed items (in {tagFeed.Value.Pages} pages) [{currentUser.UserName}]: {tagFeed.Value.Medias.Count}");
+ foreach (var media in tagFeed.Value.Medias)
+ ConsoleUtils.PrintMedia("Tag feed", media, _maxDescriptionLength);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/InstaSharper.Examples/Samples/CommentMedia.cs b/InstaSharper.Examples/Samples/CommentMedia.cs
new file mode 100644
index 00000000..b8e1c038
--- /dev/null
+++ b/InstaSharper.Examples/Samples/CommentMedia.cs
@@ -0,0 +1,23 @@
+using System;
+using InstaSharper.API;
+
+namespace InstaSharper.Examples.Samples
+{
+ internal class CommentMedia
+ {
+ private readonly IInstaApi _instaApi;
+
+ public CommentMedia(IInstaApi instaApi)
+ {
+ _instaApi = instaApi;
+ }
+
+ public void DoShow()
+ {
+ var commentResult = _instaApi.CommentMedia("", "Hi there!");
+ Console.WriteLine(commentResult.Succeeded
+ ? $"Comment created: {commentResult.Value.Pk}, text: {commentResult.Value.Text}"
+ : $"Unable to create comment: {commentResult.Info.Message}");
+ }
+ }
+}
\ No newline at end of file
diff --git a/InstaSharper.Examples/Samples/UploadPhoto.cs b/InstaSharper.Examples/Samples/UploadPhoto.cs
new file mode 100644
index 00000000..b11915ca
--- /dev/null
+++ b/InstaSharper.Examples/Samples/UploadPhoto.cs
@@ -0,0 +1,31 @@
+using System;
+using System.IO;
+using InstaSharper.API;
+using InstaSharper.Classes.Models;
+
+namespace InstaSharper.Examples.Samples
+{
+ internal class UploadPhoto
+ {
+ private readonly IInstaApi _instaApi;
+
+ public UploadPhoto(IInstaApi instaApi)
+ {
+ _instaApi = instaApi;
+ }
+
+ public void DoShow()
+ {
+ var mediaImage = new MediaImage
+ {
+ Height = 1080,
+ Width = 1080,
+ URI = new Uri(Path.GetFullPath(@"c:\someawesomepicture.jpg"), UriKind.Absolute).LocalPath
+ };
+ var result = _instaApi.UploadPhoto(mediaImage, "someawesomepicture");
+ Console.WriteLine(result.Succeeded
+ ? $"Media created: {result.Value.Pk}, {result.Value.Caption}"
+ : $"Unable to upload photo: {result.Info.Message}");
+ }
+ }
+}
\ No newline at end of file
diff --git a/InstaSharper.Examples/Utils/ConsoleUtils.cs b/InstaSharper.Examples/Utils/ConsoleUtils.cs
new file mode 100644
index 00000000..173f5476
--- /dev/null
+++ b/InstaSharper.Examples/Utils/ConsoleUtils.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using InstaSharper.Classes.Models;
+
+namespace InstaSharper.Examples.Utils
+{
+ public static class ConsoleUtils
+ {
+ public static void PrintMedia(string header, InstaMedia media, int maxDescriptionLength)
+ {
+ Console.WriteLine(
+ $"{header} [{media.User.UserName}]: {media.Caption?.Text.Truncate(maxDescriptionLength)}, {media.Code}, likes: {media.LikesCount}, multipost: {media.IsMultiPost}");
+ }
+ }
+}
\ No newline at end of file
diff --git a/InstaSharper.Examples/Utils/StringExtensions.cs b/InstaSharper.Examples/Utils/StringExtensions.cs
index 5b757da7..b8cad66f 100644
--- a/InstaSharper.Examples/Utils/StringExtensions.cs
+++ b/InstaSharper.Examples/Utils/StringExtensions.cs
@@ -13,4 +13,4 @@ public static string Truncate(this string value, int maxChars)
return value.Length <= maxChars ? value : value.Substring(0, maxChars) + "...";
}
}
-}
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index b0ed0a58..e7f5717d 100644
--- a/README.md
+++ b/README.md
@@ -62,13 +62,12 @@ Currently the library supports following coverage of the following Instagram API
- [x] Delete comment
- [x] Upload photo
-- [] Get followings list
+- [ ] Get followings list
* Get user list autocomplete
* Register new user
* Get megaphone log
* Explore feed
-
* Upload video
* Upload story
* Get full account backup
@@ -123,7 +122,7 @@ IResult feed = await api.GetUserFeedAsync();
IResult postResult = await apiInstance.CommentMediaAsync("1234567891234567891_123456789", "Hi there!");
```
-######for more samples you can look for [Examples folder](https://github.com/a-legotin/InstaSharper/tree/master/InstaSharper.Examples)
+#####for more samples you can look for [Examples folder](https://github.com/a-legotin/InstaSharper/tree/master/InstaSharper.Examples)
#### [Why two separate repos with same mission?](https://github.com/a-legotin/InstagramAPI-Web/wiki/Difference-between-API-Web-and-just-API-repositories)