/// <summary> /// This method does the login for the end user. It opens the url generated by <code>TwitterInterface</code> and waits /// for the PIN to be entered by the user. If the PIN is valid the method ends. If not the method goes into a loop /// and the loop ends once a succesful pin was entered. /// </summary> /// <param name="ti">A TwitterInterface Instantce</param> public static void doLogin(TwitterInterface ti) { Console.BackgroundColor = ConsoleColor.DarkCyan; Console.Clear(); TextUtils.logoName(21, 2); Console.BackgroundColor = ConsoleColor.Gray; TextUtils.blankRegion(Console.BufferWidth / 4, 15, Console.BufferWidth / 2, 4); //Console.WriteLine("A window in your default broswer should have lanuched.\nEnter the PIN shown:"); string message = "/f00A window in your default browser should have \nlaunched.\nEnter the PIN shown:\n"; TextUtils.writeTextInBox(message, Console.BufferWidth / 4, 15, Console.BufferWidth / 2); displayLaunchUri(ti); String pin = Console.ReadLine(); Boolean loginResult = ti.setOAuthWithPin(pin); while (!loginResult) { // The following line results in an error //TextUtils.writeFormattedText("/f" + TextUtils.colorToString(TextUtils.colors.cyan) + "The given PIN was invalid. A new window has appeared." + "/f" + TextUtils.colorToString(TextUtils.colors.gray) + " "); //Console.WriteLine("The given PIN was invalid. A new window has appeared.\nPlease enter the new PIN."); string errorMessage = "The given PIN was invalid. A new window has appeared.\nPlease enter the new PIN."; TextUtils.blankRegion(Console.BufferWidth / 4, 15, Console.BufferWidth / 2, 4); TextUtils.writeTextInBox(errorMessage, Console.BufferWidth / 4, 15, Console.BufferWidth / 2); displayLaunchUri(ti); pin = Console.ReadLine(); loginResult = ti.setOAuthWithPin(pin); // May need to place a wait here to prevent API overrate issues -- Matthew Burket (04/11/2014) } Console.ForegroundColor = ConsoleColor.Gray; Console.BackgroundColor = ConsoleColor.Black; }
public static void drawHeader(TwitterInterface ti) { string formatted = ""; Console.BackgroundColor = ConsoleColor.DarkCyan; TextUtils.blankRegion(0, 0, Console.BufferWidth, 3); formatted = String.Format("TwitterTXT - {0} /f10/b04", ti.screenanme); TextUtils.writeTextInBox(formatted, 1, 1, Console.BufferWidth); }
public async Task init() { twitter = new TwitterInterface(hashtag, startTime); noNetwork = !TwitterInterface.IsInternet(); if (noNetwork) { return; } await twitter.init(); await twitter.SearchTimeline(0, 40); if (twitter.data.statuses.Count != 0) { AddRange(twitter.data.statuses); noData = false; } }
/// <summary> /// The function to call when the twitter application is selected. /// </summary> /// <param name="name"> "Twitter app" </param> void ITvApp.ItemCallback(string name) { // Deactivate menu. menuFact.SetActiveMenu(null); Menu tweets = menuFact.CreateMenu(TvMenuFactory.Type.SOCIAL_MENU, "TwitterMenu"); if (tweets != null) { // Show twitters TwitterInterface.GetTwitters(display.transform.parent.GetComponent <SmartTv>(), 20, (bool success, string response) => { if (success) { TwitterResponse tresponse = JsonUtility.FromJson <TwitterResponse> (response); // Print the tweets and their author. for (int i = 0; i < tresponse.items.Length; ++i) { // display.transform.parent.GetComponent<SmartTv>().StartCoroutine(DownloadImage(tresponse.items[i].user.profile_background_image_url, image)); string [] fields = { tresponse.items[i].user.name, tresponse.items[i].text }; Menu.MenuItem item = new Menu.MenuItem(); item.name = "tweet" + i; item.fields = fields; tweets.AddMenuItem(item, (string nm) => {}); } menuFact.SetActiveMenu("TwitterMenu"); } else { Debug.Log(response); } }); } else { menuFact.SetActiveMenu("TwitterMenu"); } }
private static void displayLaunchUri(TwitterInterface ti) { String url = ti.getLoginUrl(); System.Diagnostics.Process.Start(url); }