Beispiel #1
0
 static void SendNormalPost(string message, string aPIMobile, string aPIId)
 {
     try
     {
         string         url     = GetHost("API");// "https://whatsappapi.net/API";
         HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
         request.Method      = "POST";
         request.ContentType = "application/x-www-form-urlencoded; charset=ISO-8859-1";
         request.Headers.Add("X-APIId", aPIId);
         request.Headers.Add("X-APIMobile", aPIMobile);
         LowLevelHttpDumper.Dump(request, message);
         Console.WriteLine(aPIId);
         Console.WriteLine(aPIMobile);
         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();
 }
Beispiel #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();
 }
Beispiel #3
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();
        }
Beispiel #4
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();
        }
Beispiel #5
0
        static void SendNormal(IUser user, bool doCreditRequest = false)
        {
            try
            {
                string message = doCreditRequest ? "" : getMessage(user);

                string         url     = GetHost(doCreditRequest ? "APICredit" : "API");// "https://whatsappapi.net/API";
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.Method      = doCreditRequest ? "GET" : "POST";
                request.ContentType = "application/x-www-form-urlencoded";
                request.Headers.Add("X-APIId", user.getId());
                if (!doCreditRequest)
                {
                    request.Headers.Add("X-APIMobile", user.getMobile());
                }
                LowLevelHttpDumper.Dump(request, message);
                Console.WriteLine(user.getId());
                Console.WriteLine(user.getMobile());
                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();
        }