So I am using InstaSharper, and I want to make the user to type in their name of target user, however, Instead of processing the data, it just does nothing at all. Here's my code:
class Program
{
//username and pass
#region Hidden
#endregion
private static UserSessionData user;
private static IInstaApi api;
static void Main(string[] args)
{
string inputUser;
string inputPass;
Console.WriteLine("Enter the username");
inputUser = Console.ReadLine();
Console.WriteLine("Enter your password:");
inputPass = Console.ReadLine();
user = new UserSessionData();
user.UserName = inputUser;
user.Password = inputPass;
Login();
Console.Read();
}
public static async void Login()
{
//login attempt
api = InstaApiBuilder.CreateBuilder()
.SetUser(user)
.UseLogger(new DebugLogger(LogLevel.Exceptions))
.Build();
var loginRequest = await api.LoginAsync();
if (loginRequest.Succeeded)
{
string targetUser;
Console.WriteLine("Logged in!\n\t");
Console.WriteLine("Now enter the target user");
targetUser = Console.ReadLine();
PullUserPosts(targetUser);
}
else
{
Console.WriteLine("Error logging in, are you sure you have entered the right credentials?");
}
}
public static async void PullUserPosts(string userToScrape)
{
//instagram show followers demo
var userinfo = await api.GetUserInfoByIdAsync(123456789);
Console.WriteLine($"USER: {userinfo.Value.FullName}\n\tFollowers: {userinfo.Value.FollowerCount} \n \t Is it verified?\n\t {userinfo.Value.IsVerified}\n\t\n\t");
Console.WriteLine("Loading all posts and captions by target user.. \n\t");
IResult<InstaMediaList> media = await api.GetUserMediaAsync(userToScrape, PaginationParameters.MaxPagesToLoad(5));
List<InstaMedia> mediaList = media.Value.ToList();
for (int i = 0; i < mediaList.Count; i++)
{
InstaMedia m = mediaList[i];
if (m != null && m.Caption != null)
{
string captionText = m.Caption.Text;
if (captionText != null)
{
if (m.MediaType == InstaMediaType.Image)
{
for (int x = 0; x < m.Images.Count; x++)
{
if (m.Images[x] != null && m.Images[x].URI != null)
{
Console.WriteLine($"\n\t{captionText}\n\t");
string uri = m.Images[x].URI;
Console.Write($"{uri}\n\t");
}
}
}
}
}
}
it manages to log in, but when I tell user to "Now enter the target user", nothing happened. Does anyone know how to fix it?