예제 #1
0
        public async Task DoShow()
        {
            var recipientsResult = await _instaApi.GetRankedRecipientsAsync();

            if (!recipientsResult.Succeeded)
            {
                Console.WriteLine("Unable to get ranked recipients");
                return;
            }
            Console.WriteLine($"Got {recipientsResult.Value.Items.Count} ranked threads");
            foreach (var thread in recipientsResult.Value.Items)
            {
                Console.WriteLine($"Threadname: {thread.ThreadTitle}, users: {thread.Users.Count}");
            }

            var inboxThreads = await _instaApi.GetDirectInboxAsync();

            if (!inboxThreads.Succeeded)
            {
                Console.WriteLine("Unable to get inbox");
                return;
            }
            Console.WriteLine($"Got {inboxThreads.Value.Inbox.Threads.Count} inbox threads");
            foreach (var thread in inboxThreads.Value.Inbox.Threads)
            {
                Console.WriteLine($"Threadname: {thread.Title}, users: {thread.Users.Count}");
            }
            var firstThread       = inboxThreads.Value.Inbox.Threads.FirstOrDefault();
            var sendMessageResult = await _instaApi.SendDirectMessage($"{firstThread.Users.FirstOrDefault()?.Pk}",
                                                                      firstThread.ThreadId, "test");

            Console.WriteLine(sendMessageResult.Succeeded ? "Message sent" : "Unable to send message");
        }
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var messages = await Api.GetDirectInboxAsync();

            if (messages.Succeeded)
            {
                pnlConversations.Children.Clear();
                foreach (var thread in messages.Value.Inbox.Threads)
                {
                    pnlConversations.Children.Add(new InboxThreadView(thread));
                }
            }
            else
            {
                MessageBox.Show(messages.Info.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #3
0
        public async Task DoShow()
        {
            var recipientsResult = await _instaApi.GetRankedRecipientsAsync();

            if (!recipientsResult.Succeeded)
            {
                Console.WriteLine("Unable to get ranked recipients");
                return;
            }
            Console.WriteLine($"Got {recipientsResult.Value.Threads.Count} ranked threads");
            foreach (var thread in recipientsResult.Value.Threads)
            {
                Console.WriteLine($"Threadname: {thread.ThreadTitle}, users: {thread.Users.Count}");
            }

            var inboxThreads = await _instaApi.GetDirectInboxAsync(PaginationParameters.MaxPagesToLoad(2));

            if (!inboxThreads.Succeeded)
            {
                Console.WriteLine("Unable to get inbox");
                return;
            }
            Console.WriteLine($"Got {inboxThreads.Value.Inbox.Threads.Count} inbox threads");
            foreach (var thread in inboxThreads.Value.Inbox.Threads)
            {
                Console.WriteLine($"Threadname: {thread.Title}, users: {thread.Users.Count}");
            }
            var firstThread = inboxThreads.Value.Inbox.Threads.FirstOrDefault();
            // send message to specific thread
            var sendMessageResult = await _instaApi.SendDirectMessage($"{firstThread.Users.FirstOrDefault()?.Pk}",
                                                                      firstThread.ThreadId, "test");

            Console.WriteLine(sendMessageResult.Succeeded ? "Message sent" : "Unable to send message");

            // just send message to user (thread not specified)
            sendMessageResult = await _instaApi.SendDirectMessage($"{firstThread.Users.FirstOrDefault()?.Pk}", string.Empty, "one more test");

            Console.WriteLine(sendMessageResult.Succeeded ? "Message sent" : "Unable to send message");
        }