Guest User

Untitled

a guest
Jul 18th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. // Copyright (c) 2007, Jonas Follesø
  2. // All rights reserved.
  3. //
  4. // Redistribution and use in source and binary forms, with or without
  5. // modification, are permitted provided that the following conditions are met:
  6. // * Redistributions of source code must retain the above copyright
  7. // notice, this list of conditions and the following disclaimer.
  8. // * Redistributions in binary form must reproduce the above copyright
  9. // notice, this list of conditions and the following disclaimer in the
  10. // documentation and/or other materials provided with the distribution.
  11. // * Neither the name of the Jonas Follesø nor the
  12. // names of its contributors may be used to endorse or promote products
  13. // derived from this software without specific prior written permission.
  14. //
  15. // THIS SOFTWARE IS PROVIDED BY Jonas Follesø ``AS IS'' AND ANY
  16. // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. // DISCLAIMED. IN NO EVENT SHALL Jonas Follesø BE LIABLE FOR ANY
  19. // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22. // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25.  
  26. using System;
  27. using System.IO;
  28. using System.Net;
  29. using System.Text;
  30. using System.Collections.Generic;
  31. using System.Text.RegularExpressions;
  32. using Ung1881;
  33. namespace ConsoleScraper
  34. {
  35. class Program
  36. {
  37. static void Main(string[] args)
  38. {
  39. try
  40. {
  41. //Check that we have at least four arguments (username, password, number, message)
  42. if (args.Length < 4)
  43. {
  44. Console.WriteLine("Usage: SMS username password number message");
  45. }
  46. else
  47. {
  48. //Extract variables from arguments.
  49. string username = args[0];
  50. string password = args[1];
  51. string number = args[2];
  52. string message = string.Empty;
  53.  
  54. //Build up the message.
  55. for (int i = 3; i < args.Length; ++i)
  56. {
  57. message += args[i];
  58.  
  59. //Add space if this isn't the last word of the message.
  60. message += (i == args.Length - 1) ? string.Empty : " ";
  61. }
  62.  
  63. Console.WriteLine("Sending message \"{0}\" to number {1}", message, number);
  64.  
  65. //Send the message.
  66. Ung1881Client client = new Ung1881Client(username, password);
  67. client.SendMessage(number, message);
  68. Console.WriteLine("Message \"{0}\" sent to number {1}", message, number);
  69. }
  70. }
  71. catch (Exception ex)
  72. {
  73. //Simple exception handling.
  74. Console.WriteLine(ex.ToString());
  75. }
  76. }
  77. }
  78. }
Add Comment
Please, Sign In to add comment