Building a C# WPF Twitter Reader with REST API

View: 211    Dowload: 1   Comment: 0   Post by: admin   Category: Visual studio & .NET   Fields: Other

Download  building-a-c-wpf-twitter.rar (579.79 KB)

You need to Sign In to download the file building-a-c-wpf-twitter.rar
If you do not have an account then Sign up for free here

Create a C# WPF app to read Twitter tweets and retweets via REST API with grouping related users / friends by categories

Introduction

(A quick note: if you downloaded this app's souce code before, it's been updated.)

As a Twitter user, you may follow a number of interesting people and organizations to read their tweets and retweets. It can be quite helpful if you group users in categories and focus on certain types of users at a particular time, cutting down noises from the rest. If you have multiple Twitter login accounts, you may want to switch between the accounts quickly and easily.

Background

Twitter provides a development platform for developers. You can use REST API + OAuth to access tweets and retweets: https://developer.twitter.com.

With my app, you can read tweets and retweets with a pre-defined Twitter login I created. You can also register a Twitter app at https://apps.twitter.com with your own Twitter account and use the credentials to see your Twitter login in action! See TwitterCredentialsSetup.txt in download.

From a technical point of view, you can review or learn how the following techniques are being applied:

  • C# 6 / WPF / TreeView TabControl ListView ContextMenu / MVVM / ...
  • REST API / OAuth / Json Serialization / HttpClient HttpClientHandler / ...

Using the Code

When launched, the app looks like this:

The testing login TweetTesterNET (screen name) in the dropdown list follows 7 users in 3 groups. The Generate Groups button is for a one-time function to create the 3 pre-defined groups (already done in the screenshot). If you have multiple Twitter login accounts, you can prepare them in json files to be loaded into the dropdown list.

As shown, .NET Team (@dotnet) is the selected user, and its tweets and retweets are displayed in a TabControlon the right.

There are 2 projects. TwitterAccess is a class library containing 'Twitter APIs'. TwitterReader is the WPF app.

TweetEntity represents a tweet, containing IdFullTextCreatedBy, etc. Entities are serialized and deserialized Newtonsoft.Json for REST API.

public class TweetEntity
{                
    [JsonProperty("id")]
    public long Id { get; set; }        
        
    [JsonProperty("full_text")]
    public string FullText { get; set; }

    [JsonProperty("user")]
    public UserEntity CreatedBy { get; set; }
...
}

To get tweets and retweets for a user, use this method:

public List GetUserTweetList(long userId, int count, bool includeRetweet = false)
{
    var twitterQuery = TwitterQuery.Create(HttpMethod.Get, TwitterConstants.UserTweetsUrl);
    twitterQuery.AddParameter("user_id", userId);
    twitterQuery.AddParameter("include_rts", includeRetweet);
    twitterQuery.AddParameter("exclude_replies", false);
    twitterQuery.AddParameter("contributor_details", false);
    twitterQuery.AddParameter("count", count);
    twitterQuery.AddParameter("trim_user", false);
    twitterQuery.AddParameter("include_entities", true);
    twitterQuery.AddParameter("tweet_mode", "extended");
 
    string result = ExecuteQuery(twitterQuery);
    var tweetList = JsonHelper.DeserializeToClass>(result);
    return tweetList ?? new List();
}

Building a C# WPF Twitter Reader with REST API

Create a C# WPF app to read Twitter tweets and retweets via REST API with grouping related users / friends by categories

Posted on 26-03-2018 

Comment:

To comment you must be logged in members.

Files with category

  • Folder Locker 7.0

    Folder Locker 7.0

    View: 74    Download: 1   Comment: 0

    Category: Visual studio & .NET     Fields: none

    Folder Lock is great security app that lets you password-protect files, folders and drives; encrypt your important files on-the-fly, backup files in real-time, protect portable drives, shred files & drives and clean history. Folder Lock can...

  • Bakeshop Inventory System in VB.Net and MS Access Database

    Bakeshop Inventory System in VB.Net and MS Access Database

    View: 19    Download: 1   Comment: 0

    Category: Visual studio & .NET     Fields: none

    Bakeshop Inventory System is a software based system especially designed for a Bakeshop business and for the inventory process. This system will be able to track the daily, weekly, monthly and yearly inventory of products. In this way, the staff can...

  • Bezier Curve Machine Learning Demonstration

    Bezier Curve Machine Learning Demonstration

    View: 13    Download: 0   Comment: 0

    Category: Visual studio & .NET     Fields: Other

    I enjoy working with longitudinal data. This is the second article in a series about using Bezier curves to smooth large data point fluctuations and improve the visibility of the patterns unfolding. This current article focuses on using machine...

  • Basic Library Management System

    Basic Library Management System

    View: 53    Download: 1   Comment: 0

    Category: Visual studio & .NET     Fields: none

    Library System is designed to store students (borrowers) info and their individual file in an institution regarding on the library transactions. This system is a user-friendly program able to print reports, view students’ file or transactions in the...

  • School Equipment Monitoring System with Barcode Scanner

    School Equipment Monitoring System with Barcode Scanner

    View: 64    Download: 2   Comment: 0

    Category: Visual studio & .NET     Fields: none

    This automated monitoring system aims to easily track the school equipment because there are times that the items accessed by many users have the tendency of loss due to poor monitoring of the items . This system can help you monitor the items...

  • Payroll System

    Payroll System

    View: 105    Download: 0   Comment: 0

    Category: Visual studio & .NET     Fields: none

    This Payroll system is a software based that is very simple-to-use yet powerful. This involves everything that has to do with the payment of employee. This system also includes tasks such as calculating the wages, tracking of hours (overtime and...

  • Student's Individual Inventory Record System with SMS Notification

    Student's Individual Inventory Record System with SMS Notification

    View: 91    Download: 6   Comment: 0

    Category: Visual studio & .NET     Fields: none

    This Student’s Individual Inventory Record System with SMS Notification for schools and colleges provides complete information of every enrolled student. In this way the system can easily check or track the student’s information . Then, it also...

  • Best Hotel Management Software |Hotel Management System

    Best Hotel Management Software |Hotel Management System

    View: 114    Download: 18   Comment: 0

    Category: Visual studio & .NET     Fields: Game - Entertainment

    This Hotel Management System is Best Hotel Management Software Developed using VB.Net as Front end and Sql Server as Back End.This Hotel Management System Includes All The Features Required In Hotel Software. For Example : Reservation Front office...

 
File suggestion for you
File top downloads
Codetitle - library source code to share, download the file to the community
Copyright © 2018. All rights reserved. codetitle Develope by Vinagon .Ltd