-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change state saving to return stream
- Loading branch information
Showing
27 changed files
with
235 additions
and
191 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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,9 @@ | ||
using System.Threading.Tasks; | ||
|
||
namespace InstaSharper.Examples.Samples | ||
{ | ||
internal interface IDemoSample | ||
{ | ||
Task DoShow(); | ||
} | ||
} |
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,41 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using InstaSharper.API; | ||
using InstaSharper.API.Builder; | ||
|
||
namespace InstaSharper.Examples.Samples | ||
{ | ||
internal class SaveLoadState : IDemoSample | ||
{ | ||
private readonly IInstaApi _instaApi; | ||
|
||
public SaveLoadState(IInstaApi instaApi) | ||
{ | ||
_instaApi = instaApi; | ||
} | ||
|
||
public async Task DoShow() | ||
{ | ||
var result = await _instaApi.GetCurrentUserAsync(); | ||
if (!result.Succeeded) | ||
{ | ||
Console.WriteLine($"Unable to get current user using current API instance: {result.Info}"); | ||
return; | ||
} | ||
Console.WriteLine($"Got current user: {result.Value.UserName} using existing API instance"); | ||
var stream = _instaApi.GetStateDataAsStream(); | ||
var anotherInstance = InstaApiBuilder.CreateBuilder() | ||
.SetRequestDelay(TimeSpan.FromSeconds(2)) | ||
.Build(); | ||
anotherInstance.LoadStateDataFromStream(stream); | ||
var anotherResult = await anotherInstance.GetCurrentUserAsync(); | ||
if (!anotherResult.Succeeded) | ||
{ | ||
Console.WriteLine($"Unable to get current user using current API instance: {result.Info}"); | ||
return; | ||
} | ||
Console.WriteLine( | ||
$"Got current user: {anotherResult.Value.UserName} using new API instance without re-login"); | ||
} | ||
} | ||
} |
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,35 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using InstaSharper.API; | ||
|
||
namespace InstaSharper.Examples.Samples | ||
{ | ||
internal class Stories : IDemoSample | ||
{ | ||
private readonly IInstaApi _instaApi; | ||
|
||
public Stories(IInstaApi instaApi) | ||
{ | ||
_instaApi = instaApi; | ||
} | ||
|
||
public async Task DoShow() | ||
{ | ||
var result = await _instaApi.GetStoryFeedAsync(); | ||
if (!result.Succeeded) | ||
{ | ||
Console.WriteLine($"Unable to get story feed: {result.Info}"); | ||
return; | ||
} | ||
var storyFeed = result.Value; | ||
Console.WriteLine($"Got {storyFeed.Items.Count} story reels."); | ||
foreach (var feedItem in storyFeed.Items) | ||
{ | ||
Console.WriteLine($"User: {feedItem.User.FullName}"); | ||
foreach (var item in feedItem.Items) | ||
Console.WriteLine( | ||
$"Story item: {item.Caption?.Text ?? item.Code}, images:{item.ImageList?.Count ?? 0}, videos: {item.VideoList?.Count ?? 0}"); | ||
} | ||
} | ||
} | ||
} |
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
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
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.