Example #1
0
        public static void AddToFree(IMyLog log, QuestionOption it)
        {
            try
            {
                string email   = Question.Ask("Email");
                string telList = Question.Ask("TelList");

                string         url     = WhatsappMessages.GetHost("APIPrivAddTel");
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method      = "POST";
                request.ContentType = "application/x-www-form-urlencoded";
                request.Headers.Add("X-EmailB64", Convert.ToBase64String(Encoding.ASCII.GetBytes(email)));
                request.Headers.Add("X-TelList", telList);
                LowLevelHttpDumper.Dump(request);
                using (StreamWriter streamOut = new StreamWriter(request.GetRequestStream()))
                {
                    streamOut.Write(" ");
                }
                using (StreamReader streamIn = new StreamReader(request.GetResponse().GetResponseStream()))
                {
                    Console.WriteLine(streamIn.ReadToEnd());
                }
            }
            catch (SystemException se)
            {
                Console.WriteLine(se.Message);
            }
            Console.ReadLine();
        }
Example #2
0
 static void AddNumber()
 {
     try
     {
         string         instruction = "Add";
         string         message     = "<TelNumbers>";
         string         method      = "POST";
         string         url         = WhatsappMessages.GetHost("APITelNumbers");// "https://whatsappapi.net/API";
         HttpWebRequest request     = (HttpWebRequest)WebRequest.Create(url);
         request.Method      = method;
         request.ContentType = "application/x-www-form-urlencoded";
         request.Headers.Add("X-APIId", "<ApiId>");
         request.Headers.Add("X-APIInstruction", instruction);
         LowLevelHttpDumper.Dump(request, message);
         Console.WriteLine(instruction);
         Console.WriteLine(message);
         if (!string.IsNullOrWhiteSpace(message))
         {
             using (StreamWriter streamOut = new StreamWriter(request.GetRequestStream()))
             {
                 streamOut.Write(message);
             }
         }
         using (StreamReader streamIn = new StreamReader(request.GetResponse().GetResponseStream()))
         {
             Console.WriteLine(streamIn.ReadToEnd());
         }
     }
     catch (SystemException se)
     {
         Console.WriteLine(se.Message);
     }
     Console.ReadLine();
 }
Example #3
0
        static void SendNormal(IUser user)
        {
            try
            {
                string instruction = getInstruction(user);
                string message     = "";
                string method      = "GET";
                switch (instruction)
                {
                case "Add":
                case "Remove":
                    message = getTelNumbers(user);
                    method  = "POST";
                    break;
                }

                string         url     = WhatsappMessages.GetHost("APITelNumbers");// "https://whatsappapi.net/API";
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method      = method;
                request.ContentType = "application/x-www-form-urlencoded";
                request.Headers.Add("X-APIId", user.getId());
                request.Headers.Add("X-APIInstruction", instruction);
                LowLevelHttpDumper.Dump(request, message);
                Console.WriteLine(user.getId());
                Console.WriteLine(instruction);
                Console.WriteLine(message);
                if (!string.IsNullOrWhiteSpace(message))
                {
                    using (StreamWriter streamOut = new StreamWriter(request.GetRequestStream()))
                    {
                        streamOut.Write(message);
                    }
                }
                using (StreamReader streamIn = new StreamReader(request.GetResponse().GetResponseStream()))
                {
                    Console.WriteLine(streamIn.ReadToEnd());
                }
            }
            catch (SystemException se)
            {
                Console.WriteLine(se.Message);
            }
            Console.ReadLine();
        }
Example #4
0
 public static void SendTelSync(IMyLog log, QuestionOption it)
 {
     if (Question.Ask("This is dangerous, Do you really want to do that? (Y)", "Y"))
     {
         try
         {
             string url = WhatsappMessages.GetHost("ItemX");// "https://whatsappapi.net/API";
             url += "?id=GetAllTelNumbers";
             if (Question.Ask("Add at least a noSync=1 (y)", "y"))
             {
                 url += "&noSync=1";
             }
             Console.WriteLine("Your url is:");
             Console.WriteLine(url);
             if (Question.Ask("Use it? (Y)", "Y"))
             {
                 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                 //                    request.Method = "POST";
                 //                    request.ContentType = "application/x-www-form-urlencoded";
                 //                    request.Headers.Add("id", "GetAllTelNumbers");
                 //using (StreamWriter streamOut = new StreamWriter(request.GetRequestStream()))
                 //{
                 //    streamOut.Write("");
                 //}
                 using (StreamReader streamIn = new StreamReader(request.GetResponse().GetResponseStream()))
                 {
                     Console.WriteLine(streamIn.ReadToEnd());
                 }
             }
         }
         catch (SystemException se)
         {
             Console.WriteLine(se.Message);
         }
         Question.Ask("Done");
     }
 }