示例#1
0
文件: ChatHub.cs 项目: gitues/chat
        public void login(string phoneNumber, string pass)
        {
            Thread thread = new Thread(t =>
            {
                wa = new WhatsApp(phoneNumber, pass, phoneNumber, true);
                wa.OnConnectSuccess += () =>
                {
                    Clients.All.notifyMessage("Conectado ...");

                    wa.OnLoginSuccess += (phone, data) =>
                    {
                        Clients.All.notifyMessage("Logueo exitoso ...");
                    };

                    wa.OnLoginFailed += (data) =>
                    {
                        Clients.All.notifyMessage(string.Format("Fallo en login {0}", data));
                    };
                    wa.Login();
                };

                wa.OnConnectFailed += (ex) =>
                {
                    Clients.All.notifyMessage(string.Format("Fallo de conexión {0}", ex.StackTrace));
                };

                wa.Connect();
            })
            {
                IsBackground = true
            };

            thread.Start();
        }
示例#2
0
        private void btnGonder_Click(object sender, EventArgs e)
        {
            WhatsApp wa = new WhatsApp(txtTelefon.Text, txtPassword.Text, txtIsım.Text, true);

            wa.OnConnectSuccess += () =>
            {
                txtDurum.Text      = "Bağlandıı..";
                wa.OnLoginSuccess += (phone, data) =>
                {
                    txtDurum.Text += "\r\n Bağlantı başarılı!";
                    wa.SendMessage(txtKime.Text, txtMesaj.Text);
                    txtDurum.Text += "\r\n Mesaj gönderildi";
                };
                wa.OnLoginFailed += (data) =>
                {
                    txtDurum.Text += string.Format("\r\n Giriş başarısız {0}", data);
                };
                wa.Login();
            };
            wa.OnConnectFailed += (ex) =>
            {
                txtDurum.Text += string.Format("\r\n Bağlantı başarısız {0}", ex.StackTrace);
            };
            wa.Connect();
        }
示例#3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string from = "56966411028";
            string to   = txtTo.Text;
            string msg  = txtMessage.Text;

            WhatsApp wa = new WhatsApp(from, "2kVzSn7Mf2CP09+LnqVs+t9EWy8=", "rodrigo", false, false);

            wa.OnConnectSuccess += () =>
            {
                MessageBox.Show("Conectando a WhatsAppa");

                wa.OnLoginSuccess += (phoneNumber, data) =>
                {
                    wa.SendMessage(to, msg);
                    MessageBox.Show("Mensaje enviado");
                };

                wa.OnLoginFailed += (data) =>
                {
                    MessageBox.Show(string.Format("Fallo login : {0} ", data));
                };

                wa.Login();
            };

            wa.OnConnectFailed += (ex) =>
            {
                MessageBox.Show("Fallo la conexion");
            };

            wa.Connect();

            //WIhDFaZ/gB4kEv6fk/d9h7rlhJY=
        }
示例#4
0
        public void SendMessage()
        {
            //WhatsApp wa = new WhatsApp("918971503323", "865980025606754", "Goku", true);
            WhatsApp wa = new WhatsApp("918971503323", "VrF2co5YusQHfEr9KYcRFzHLywg=", "Goku", true);

            //eb+rLdDbcsKrfsodefDuqRSRxhU=
            //Base64Encode("867802024224934")

            wa.OnConnectSuccess += () =>
            {
                //wa.SendMessage("8105446053", "Hello");

                wa.OnLoginSuccess += (phno, data) =>
                {
                    wa.SendMessage("8105446053", "Hello");
                };

                wa.OnLoginFailed += (data) =>
                {
                    System.Diagnostics.Debug.Write("Login failed");
                };
                wa.Login();
            };
            wa.OnConnectFailed += (ex) =>
            {
                System.Diagnostics.Debug.Write("Login failed" + ex.Message);
            };

            wa.Connect();

            //wa.Disconnect();
        }
示例#5
0
        public void Start()
        {
            dtEmisores_UsuariosEN = SchoolManager.WhatsApp.LogicaNegocios.Emisores_UsuariosLN.DtEmisorActivoPorUsuario(Usuario, _prioridad);
            if (dtEmisores_UsuariosEN.Rows.Count == 0)
            {
                System.Windows.Forms.MessageBox.Show(string.Format("Usuario: {0}.- No hay emisor para enviar mensajes", Usuario));
                return;
            }
            _listen          = true;
            wa               = new WhatsApp(dtEmisores_UsuariosEN.Rows[0]["EMISOR"].ToString(), dtEmisores_UsuariosEN.Rows[0]["APIKEY"].ToString(), dtEmisores_UsuariosEN.Rows[0]["NOMBREPERFIL"].ToString(), true);
            dtUltimaConexion = DateTime.Now;
            wa.Connect();
            wa.Login();

            if (_types != null && _types.Length > 0)
            {
                // Using only the XmlMessageFormatter. You can use other formatters as well
                _queue.Formatter = new XmlMessageFormatter(_types);
            }

            _queue.PeekCompleted    += new PeekCompletedEventHandler(OnPeekCompleted);
            _queue.ReceiveCompleted += new ReceiveCompletedEventHandler(OnReceiveCompleted);

            StartListening();
        }
示例#6
0
        public void LoginWhatsapp(string phoneNumber, string password)
        {
            Thread thhread = new Thread(t =>
            {
                wa = new WhatsApp(phoneNumber, password, phoneNumber, true);
                wa.OnConnectSuccess += () =>
                {
                    Clients.All.notifyMessage("Connected......");
                    wa.OnLoginSuccess += (phone, data) =>
                    {
                        Clients.All.notifyMessage("Login Success !");
                    };
                    wa.OnLoginFailed += (data) =>
                    {
                        Clients.All.notifyMessage(string.Format("Login failed: {0}", data));
                    };
                    wa.Login();
                };
                wa.OnConnectFailed += (ex) =>
                {
                    Clients.All.notifyMessage(string.Format("Connected failed: {0}", ex.StackTrace));
                };
                wa.Connect();
            })
            {
                IsBackground = true
            };

            thhread.Start();
        }
        public void SendWhatsAppMessage(WhatsAppConfig whatsAppConfig)
        {
            WhatsApp whatsApp = new WhatsApp(whatsAppConfig.Phone, whatsAppConfig.Password,
                                             whatsAppConfig.Nickname, false, false);

            whatsApp.OnConnectSuccess += () =>
            {
                MessageBox.Show("Connected to whatsapp...");
                whatsApp.OnLoginSuccess += (phoneNumber, data) =>
                {
                    whatsApp.SendMessage(whatsAppConfig.Phone, whatsAppConfig.Message);
                    MessageBox.Show("Message Sent...");
                };

                whatsApp.OnLoginFailed += (data) =>
                {
                    MessageBox.Show("Login failed: {0}", data);
                };

                whatsApp.Login();
            };
            whatsApp.OnConnectFailed += (ex) =>
            {
                MessageBox.Show("Connected Failed...");
            };

            whatsApp.Connect();
        }
示例#8
0
 private void btnSend_Click(object sender, EventArgs e)
 {
     try
     {
         WhatsApp wa = new WhatsApp(txtPhone.Text, txtPass.Text, txtPass.Text, true);
         wa.OnConnectSuccess += () =>
         {
             txtStatus.Text     = "تم الاتصال .....";
             wa.OnLoginSuccess += (phone, data) =>
             {
                 txtStatus.Text += "\r\n تم الاتصال .....!";
                 wa.SendMessage(txtTo.Text, txtMessage.Text);
                 txtStatus.Text += "\r\n تم ارسال الرسالة !";
             };
             wa.OnLoginFailed += (data) =>
             {
                 txtStatus.Text += string.Format("\r\n Connection Failed {0}", data);
             };
             wa.Login();
         };
         wa.OnConnectFailed += (ex) =>
         {
             txtStatus.Text += string.Format("\r\n Connect Failed {0}", ex.StackTrace);
         };
         wa.Connect();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#9
0
        private void button1_Click(object sender, EventArgs e)
        {
            string from = "923059108705";
            string To   = txtTo.Text;
            string msg  = txtmsg.Text;


            WhatsApp wa = new WhatsApp(from, "604c6a32ffe14e04e999d064342551061a01c778", "Amin", false, false);

            wa.OnConnectSuccess += () =>
            {
                MessageBox.Show("Connected to Whatsapp");
                wa.OnLoginSuccess += (phoneNumber, data) =>
                {
                    wa.SendMessage(To, msg);
                    MessageBox.Show("Message send.....");
                };
                wa.OnLoginFailed += (data) =>
                {
                    MessageBox.Show("Login Failed :(0)", data);
                };
                wa.Login();
            };
            wa.OnConnectFailed += (ex) =>
            {
                MessageBox.Show("Connection Failed......");
            };
            wa.Connect();
        }
示例#10
0
        static void Main(string[] args)
        {
            string   to   = "7978406411";
            string   msg  = "Hii I am Abhijit Parida";
            string   from = "9437745159";
            WhatsApp wa   = new WhatsApp(from, "", "Abhijit", false, false);

            wa.OnConnectSuccess += () =>
            {
                Console.WriteLine(" Connected with whatsApp Successfully");
                wa.OnLoginSuccess += (phonenumber, data) =>
                {
                    wa.SendMessage(to, msg);
                };
                wa.OnLoginFailed += (data) =>
                {
                    Console.WriteLine("WhatsApp Login failed please check the error through stack trace", data);
                };
                wa.Login();
            };
            wa.OnConnectFailed += (data) =>
            {
                Console.WriteLine("Connection Failled");
            };
            wa.Connect();
        }
示例#11
0
        private static string SendMessage(String To, String Message)
        {
            string   status = string.Empty;
            WhatsApp wa     = new WhatsApp("917709981177", "xxxxxxxxxxxxxxxxxx", "Amit", false, false);

            wa.OnConnectSuccess += () =>
            {
                wa.OnLoginSuccess += (phonenumber, data) =>
                {
                    status = "Connection Success";
                    wa.SendMessage(To, Message);
                    status = "Message sent Success";
                };

                wa.OnLoginFailed += (data) =>
                {
                    status = "Login Failed" + data;
                };
                wa.Login();
            };
            wa.OnConnectFailed += (ex) =>
            {
                status = "Connection Failed" + ex.StackTrace;
            };
            wa.Connect();

            return(status);
        }
示例#12
0
        public WhatsappSender()
        {
            string from  = "hier mobiel nummer van bus-systeem";
            string token = "hier whatsapp token van WART (https://github.com/mgp25/WART)";

            WhatsApp wa = new WhatsApp(from, token, "Bus-systeem", false, false);

            wa.OnConnectSuccess += () =>
            {
                //MessageBox.Show("Connecten naar whatsapp..."); // Alleen voor testen

                wa.OnLoginSuccess += (phoneNumber, data) =>
                {
                    // wa.SendMessage(to, msg);
                    //MessageBox.Show("Bericht verstuurd.."); // Alleen voor testen
                };

                wa.OnLoginFailed += (data) =>
                {
                    //MessageBox.Show("Login mislukt : {0}", data); // Alleen voor testen
                };

                wa.Login();
            };

            wa.OnConnectFailed += (ex) =>
            {
                //MessageBox.Show("Connection mislukt"); // Alleen voor testen
            };

            wa.Connect();
        }
示例#13
0
        private static void Main(string[] args)
        {
            var tmpEncoding = Encoding.UTF8;

            System.Console.OutputEncoding = Encoding.Default;
            System.Console.InputEncoding  = Encoding.Default;
            string nickname = "WhatsAPI Test";
            string sender   = "3526********";                // Mobile number with country code (but without + or 00)
            string password = "******"; //v2 password
            string target   = "316********";                 // Mobile number to send the message to

            WhatsApp wa = new WhatsApp(sender, password, nickname, true);

            wa.Connect();
            wa.Login();
            wa.sendNickname(nickname);
            wa.Disconnect();

            wa.PresenceSubscription(target);
            wa.GetStatus(target);

            ProcessChat(wa, "");

            Console.ReadKey();
        }
示例#14
0
        private void button1_Click(object sender, EventArgs e)
        {
            string From = "918824518051";
            string To   = textBox1.Text;
            string msg  = textBox2.Text;
            //Whatsapp Class
            WhatsApp wa = new WhatsApp(From, "", "Vin", false, false);

            wa.OnConnectSuccess += () =>
            {
                MessageBox.Show("Connected to WhatsApp..........");

                wa.OnLoginSuccess += (phoneNumber, data) =>
                {
                    MessageBox.Show("Login SuccessFully!!");
                    wa.SendMessage(To, msg);
                    MessageBox.Show("Message Sent!");
                };
                wa.OnLoginFailed += (data) =>
                {
                    MessageBox.Show("Login Failed :{0}", data);
                };
                wa.Login();
            };
            wa.OnConnectFailed += (ex) =>
            {
                MessageBox.Show("Connection Failed!");
            };
            wa.Connect();
        }
示例#15
0
        private static void Main(string[] args)
        {
            var tmpEncoding = Encoding.UTF8;
            //System.Console.OutputEncoding = Encoding.Default;
            //  System.Console.InputEncoding = Encoding.Default;
            string nickname = "WhatsApiNet";
            string sender   = "972546252491";                // Mobile number with country code (but without + or 00)
            string password = "******"; //v2 password
            string target   = "972543143131";                // Mobile number to send the message to
            string text     = "בדיקה";

            WhatsApp wa = new WhatsApp(sender, password, nickname, true);

            //event bindings

            wa.OnLoginSuccess += (phoneNumber, data) =>
            {
                WhatsUserManager usrMan = new WhatsUserManager();
                var    tmpUser          = usrMan.CreateUser(target, "User");
                string sdata            = Convert.ToBase64String(data);
                wa.SendMessage(tmpUser.GetFullJid(), text);
                //wa.Disconnect();
            };
            byte[] nextChallenge = Convert.FromBase64String(sender);
            wa.Connect();
            wa.Login(nextChallenge);
            Console.ReadKey();
        }
示例#16
0
        public void SendMessage(string to, string msg)
        {
            string from = "YOUR_CEL_PHONE";

            WhatsApp wa = new WhatsApp(from, "YOUR_TOKEN_PERMISSION", "PASS", false, false);

            wa.OnConnectSuccess += () =>
            {
                wa.OnLoginSuccess += (phonenumber, data) =>
                {
                    wa.SendMessage(to, msg);
                };

                wa.OnLoginFailed += (data) =>
                {
                    string dataex = data;
                };

                wa.Login();
            };

            wa.OnConnectFailed += (ex) =>
            {
                string s = ex.Message;
            };

            wa.Connect();
        }
示例#17
0
 public Result SendByWhatsApp(string To, string Message)
 {
     result = new Result();
     if (SMSService == "True")
     {
         WhatsApp wa = new WhatsApp(WhatsappFrom, WhatsappPassword, WhatsappNickName, true, true);
         wa.OnConnectSuccess += () =>
         {
             wa.OnLoginSuccess += (phoneNumber, data) =>
             {
                 wa.SendMessage(To, Message);
                 result.Message = "Message sent successfully!";
             };
             wa.OnLoginFailed += (data) =>
             {
                 result.Message = "Login Failed : {0}," + data + "";
             };
             wa.Login();
         };
         wa.OnConnectFailed += (ex) =>
         {
             result.Message = "Connection Failed!";
         };
         wa.Connect();
     }
     return(result);
 }
示例#18
0
        private string SendWhats()
        {
            // Moto G dual chip
            // 353334061452427
            // 353334061452435

            string imei = "353334061452435"; //My IMEI

            //string imei = "00c9caf9c2ca86b624d3defcf199d4f1"; //My IMEI

            //WhatsApp me = new WhatsApp(sender, imei, nickname, true);



            WhatsApp me = null;

            using (MD5 md5Hash = MD5.Create())
            {
                String corrected = new string(imei.ToCharArray());

                string hash1 = GetMd5Hash(md5Hash, "353334061452427"); // IMEI SIM CLARO
                string hash2 = GetMd5Hash(md5Hash, "353334061452435"); // IMEI SIM TIM
                string hash3 = GetMd5Hash(md5Hash, "Android9589");     // Senha WART

                me = new WhatsApp("5521995891097", hash1, "API Test", true);
                me.Connect();
                me.Login();

                //Response.Write(me.Login(null) + " | ");

                //Response.Write(me.Login(md5Hash.ComputeHash(Encoding.Unicode.GetBytes(hash3))) + " | ");

                //    byte[] b = {
                //                   getByte("00"), getByte("c9"), getByte("ca"), getByte("f9"),
                //                   getByte("c2"), getByte("ca"), getByte("86"), getByte("b6"),
                //                   getByte("24"), getByte("d3"), getByte("de"), getByte("fc"),
                //                   getByte("f1"), getByte("99"), getByte("d4"), getByte("f1") };

                //    me.Login(b);
            }

            //using (MD5 md5Hash = MD5.Create())
            //{
            //    string hash1 = GetMd5Hash(md5Hash, "353334061452427");
            //    string hash2 = GetMd5Hash(md5Hash, "353334061452435");
            //    //string hashs = "00c9caf9c2ca86b624d3defcf199d4f1";

            //    //me.Login(md5Hash.ComputeHash(Encoding.UTF8.GetBytes(imei)));
            //}

            Response.Write(me.ConnectionStatus + " | ");                      // I get a Connection!

            Response.Write(me.SendMessage("5521969476360", "Amor! Retorna")); // Send Message

            //No Message received :(
            me.Disconnect();

            return("");
        }
示例#19
0
        private static void Main_old(string[] args)
        {
            var tmpEncoding = Encoding.UTF8;

            System.Console.OutputEncoding = Encoding.Default;
            System.Console.InputEncoding  = Encoding.Default;
            string nickname = "lior";
            string sender   = "972546252491";                 // Mobile number with country code (but without + or 00)
            string password = "******"; //v2 password
            string target   = "972543143131";                 // Mobile number to send the message to

            WhatsApp wa = new WhatsApp(sender, password, nickname, true);

            //event bindings
            wa.OnLoginSuccess             += wa_OnLoginSuccess;
            wa.OnLoginFailed              += wa_OnLoginFailed;
            wa.OnGetMessage               += wa_OnGetMessage;
            wa.OnGetMessageReceivedClient += wa_OnGetMessageReceivedClient;
            wa.OnGetMessageReceivedServer += wa_OnGetMessageReceivedServer;
            wa.OnNotificationPicture      += wa_OnNotificationPicture;
            wa.OnGetPresence              += wa_OnGetPresence;
            wa.OnGetGroupParticipants     += wa_OnGetGroupParticipants;
            wa.OnGetLastSeen              += wa_OnGetLastSeen;
            wa.OnGetTyping                     += wa_OnGetTyping;
            wa.OnGetPaused                     += wa_OnGetPaused;
            wa.OnGetMessageImage               += wa_OnGetMessageImage;
            wa.OnGetMessageAudio               += wa_OnGetMessageAudio;
            wa.OnGetMessageVideo               += wa_OnGetMessageVideo;
            wa.OnGetMessageLocation            += wa_OnGetMessageLocation;
            wa.OnGetMessageVcard               += wa_OnGetMessageVcard;
            wa.OnGetPhoto                      += wa_OnGetPhoto;
            wa.OnGetPhotoPreview               += wa_OnGetPhotoPreview;
            wa.OnGetGroups                     += wa_OnGetGroups;
            wa.OnGetSyncResult                 += wa_OnGetSyncResult;
            wa.OnGetStatus                     += wa_OnGetStatus;
            wa.OnGetPrivacySettings            += wa_OnGetPrivacySettings;
            DebugAdapter.Instance.OnPrintDebug += Instance_OnPrintDebug;

            wa.Connect();

            string datFile = getDatFileName(sender);

            byte[] nextChallenge = null;
            if (File.Exists(datFile))
            {
                try
                {
                    string foo = File.ReadAllText(datFile);
                    nextChallenge = Convert.FromBase64String(foo);
                }
                catch (Exception) { };
            }

            wa.Login(nextChallenge);

            ProcessChat(wa, target);
            Console.ReadKey();
        }
示例#20
0
 private void btnSignIn_Click(object sender, EventArgs e)
 {
     wa = new WhatsApp(Properties.Settings.Default.PhoneNumber, Properties.Settings.Default.Password, Properties.Settings.Default.FullName, true);
     wa.OnLoginSuccess  += Wa_OnLoginSuccess;
     wa.OnLoginFailed   += Wa_OnLoginFailed;
     wa.OnConnectFailed += Wa_OnConnectFailed;
     wa.Connect();
     wa.Login();
 }
示例#21
0
        bool SendWhatsAppMessage(String receiver, String Message)
        {
            bool result = false;

            try
            {
                //Send ( button_click )

                DataAccess.RedaV1Entities db      = ModuleClass.GetConnection();//= new DataAccess.RedaV1Entities(ModuleClass.Connect());
                DataAccess.Company        company = db.Companies.Take(1).SingleOrDefault();

                string WhatsAppCode   = company.WhatsAppCode;   // UserData.Default.WhatsAppCode;
                string WhatsAppSender = company.WhatsAppSender; // UserData.Default.WhatsAppSender;



                string from = WhatsAppSender;
                string to   = receiver;
                string msg  = Message;

                WhatsApp wa = new WhatsApp(from, WhatsAppCode, "RedaPos", false, true);

                wa.OnConnectSuccess += () =>
                {
                    //   MessageBox.Show("Connected to whatsapp...");

                    wa.OnLoginSuccess += (phoneNumber, data) =>
                    {
                        wa.SendMessage(to, msg);
                        result = true;
                    };

                    wa.OnLoginFailed += (data) =>
                    {
                        MessageBox.Show("Login Failed : {0}", data);
                        result = false;
                    };

                    wa.Login();
                };

                wa.OnConnectFailed += (ex) =>
                {
                    MessageBox.Show("Connection Failed...");
                    result = false;
                };

                wa.Connect();
            }
            catch (Exception ex2)
            {
                result = false;
            }

            return(result);
        }
示例#22
0
        public async Task <Response <WhatsApp> > ConnectAndLogin(string phoneSender, string pws, string nickName)
        {
            var tcs = new TaskCompletionSource <Response <WhatsApp> >();

            try
            {
                WhatsApp whatsApp = new WhatsApp(phoneSender, pws, nickName);
                whatsApp.Connect();
                // mockSend.SetSocketClient()
                whatsApp.OnLoginSuccess += (a, b) =>
                {
                    Console.WriteLine("data ok={0}", a);
                    //string m = "test me...";
                    //whatsApp.SendData(Encoding.ASCII.GetBytes(m));
                    tcs.SetResult(new Response <WhatsApp> {
                        IsError = false, Result = whatsApp
                    });
                };
                whatsApp.OnLoginFailed += (a) =>
                {
                    Console.WriteLine("data error={0}", a);
                    tcs.SetResult(new Response <WhatsApp> {
                        IsError = true, Message = a
                    });
                };
                byte[] nextChallenge = Convert.FromBase64String(phoneSender);
                whatsApp.Connect();
                whatsApp.Login(nextChallenge);
            }
            catch (Exception ee)
            {
                tcs.SetException(ee);
            }

            return(await tcs.Task);
        }
示例#23
0
 private void btnImage_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog ofd = new OpenFileDialog()
     {
         Filter = "PNG|*.png|JPG|*.jpg|*GIF|*.gif", ValidateNames = true, Multiselect = false
     })
     {
         if (ofd.ShowDialog() == DialogResult.OK)
         {
             fileName     = ofd.FileName;
             index        = ofd.FilterIndex;
             lblPath.Text = string.Format("Path: {0}", ofd.FileName);
             // timer.Stop();
             wa.Disconnect();
             Thread.Sleep(3000);
             wa.Connect();
             wa.Login();
         }
     }
 }
示例#24
0
        private static void Main(string[] args)
        {
            var tmpEncoding = Encoding.UTF8;

            System.Console.OutputEncoding = Encoding.Default;
            System.Console.InputEncoding  = Encoding.Default;
            string nickname = "WhatsApiNet";
            string sender   = "316******3";             // Mobile number with country code (but without + or 00)
            string password = "******"; //v2 password
            string target   = "316********6";           // Mobile number to send the message to

            WhatsApp wa = new WhatsApp(sender, password, nickname, true);

            //event bindings
            wa.OnLoginSuccess             += wa_OnLoginSuccess;
            wa.OnLoginFailed              += wa_OnLoginFailed;
            wa.OnGetMessage               += wa_OnGetMessage;
            wa.OnGetMessageReceivedClient += wa_OnGetMessageReceivedClient;
            wa.OnGetMessageReceivedServer += wa_OnGetMessageReceivedServer;
            wa.OnNotificationPicture      += wa_OnNotificationPicture;
            wa.OnGetPresence              += wa_OnGetPresence;
            wa.OnGetGroupParticipants     += wa_OnGetGroupParticipants;
            wa.OnGetLastSeen              += wa_OnGetLastSeen;
            wa.OnGetTyping          += wa_OnGetTyping;
            wa.OnGetPaused          += wa_OnGetPaused;
            wa.OnGetMessageImage    += wa_OnGetMessageImage;
            wa.OnGetMessageAudio    += wa_OnGetMessageAudio;
            wa.OnGetMessageVideo    += wa_OnGetMessageVideo;
            wa.OnGetMessageLocation += wa_OnGetMessageLocation;
            wa.OnGetMessageVcard    += wa_OnGetMessageVcard;
            wa.OnGetPhoto           += wa_OnGetPhoto;
            wa.OnGetPhotoPreview    += wa_OnGetPhotoPreview;
            wa.OnGetGroups          += wa_OnGetGroups;
            wa.OnGetSyncResult      += wa_OnGetSyncResult;

            wa.Connect();
            wa.Login();

            ProcessChat(wa, target);
            Console.ReadKey();
        }
示例#25
0
        public void Login(string phoneNumber, string password)
        {
            Thread thread = new Thread(t => {
                wa = new WhatsApp(phoneNumber, password, phoneNumber, true);
                wa.OnConnectSuccess += () =>
                {
                    Clients.All.notifyMessage("connected....");

                    // when login success
                    // notify the user logged in
                    // successfully ....

                    wa.OnLoginSuccess += (phone, data) =>
                    {
                        Clients.All.notifyMessage("Login success ... ");
                    };

                    // when login fails
                    // notify the user login
                    // process is failed ...

                    wa.OnLoginFailed += (data) =>
                    {
                        Clients.All.notifyMessage(string.Format("login failed : {0} ", data));
                    };

                    wa.Login();
                };

                wa.OnConnectFailed += (ex) =>
                {
                    Clients.All.notifyMessage(string.Format("Connection Failed : { 0 }", ex));
                };
                wa.Connect();
            })
            {
                IsBackground = true
            };

            thread.Start();
        }
示例#26
0
        public void Login()
        {
            try
            {
                //var rosterItem = new RosterItem()
                //{
                //    Jid = "*****@*****.**",
                //    Name = "Pradeep",
                //    Messages = new System.Collections.ObjectModel.ObservableCollection<Message>()
                //};
                //Roster.Instance.Add(rosterItem);

                client.Connect();
                //client.SendGetPhoto(rosterItem.Jid, "", false);
                //client.SendGetStatuses(new string[] { rosterItem.Jid });
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#27
0
        public static void SendWhapp()
        {
            string from     = "40733766829";
            string toMishu  = "4073100090";
            string to       = "40733766829";
            string message  = "Hey";
            string imei     = "354378062812286";
            string password = "******";
            string nick     = "Test";

            //var by = new byte[] { Convert.ToByte(imei) };
            //var base64 = Convert.ToBase64String(by);
            WhatsApp wa = new WhatsApp(from, imei, nick, true, true);

            wa.OnConnectSuccess += () =>
            {
                Console.WriteLine("Connected");
                wa.OnLoginSuccess += (phoneNumber, data) =>
                {
                    wa.SendMessage(to, message);
                    Console.WriteLine("Message send");
                };

                wa.OnLoginFailed += (data) =>
                {
                    Console.WriteLine("Fail to send");
                };

                wa.Login();
            };

            wa.OnConnectFailed += (ex) =>
            {
                Console.WriteLine("Failed to connect");
            };

            wa.Connect();
        }
        public void SendMessage(string message, string toNumber)
        {
            string from = "447885860529";
            string to   = "447474318713";
            string password;
            // var res = WhatsAppApi.Register.WhatsRegisterV2.GetToken(from);

            WhatsApp wa = new WhatsApp(from, "", "BeruwalaMirror", false, false);

            wa.OnConnectSuccess += () =>
            {
                Console.Write("Connected");
                wa.OnLoginSuccess += (phoneNumber, data) =>
                {
                    wa.SendMessage(to, message);
                    Console.Write("Message sent ...");
                };
                wa.OnLoginFailed += (data) => { Console.Write("login failed: {0}", data); };
                wa.Login();
            };
            wa.OnConnectFailed += (ex) => { Console.Write("connection failed.."); };
            wa.Connect();
        }
示例#29
0
        //private static void Main(string[] args)
        //{
        //    var tmpEncoding = Encoding.UTF8;
        //    System.Console.OutputEncoding = Encoding.Default;
        //    System.Console.InputEncoding = Encoding.Default;

        //    string sender = "5521966747230";
        //    string meuTim = "5521983486604";
        //    //string eeeeeeeepa = "5524993951862";
        //    //string vinicius = "5521976320158";
        //    //string ricardo = "5521981663664";

        //    string password = "******";
        //    string nickname = "Verision";
        //    //      string sender   = ""; // Mobile number with country code (but without + or 00)
        //    //      string password = "";//v2 password
        //    string target = meuTim;// Mobile number to send the message to

        //    WhatsApp wa = new WhatsApp(sender, password, nickname, true);

        //    //event bindings
        //    wa.OnLoginSuccess += wa_OnLoginSuccess;
        //    wa.OnLoginFailed += wa_OnLoginFailed;
        //    wa.OnGetMessage += wa_OnGetMessage;
        //    wa.OnGetMessageReadedClient += wa_OnGetMessageReadedClient;
        //    wa.OnGetMessageReceivedClient += wa_OnGetMessageReceivedClient;
        //    wa.OnGetMessageReceivedServer += wa_OnGetMessageReceivedServer;
        //    wa.OnNotificationPicture += wa_OnNotificationPicture;
        //    wa.OnGetPresence += wa_OnGetPresence;
        //    wa.OnGetGroupParticipants += wa_OnGetGroupParticipants;
        //    wa.OnGetLastSeen += wa_OnGetLastSeen;
        //    wa.OnGetTyping += wa_OnGetTyping;
        //    wa.OnGetPaused += wa_OnGetPaused;
        //    wa.OnGetMessageImage += wa_OnGetMessageImage;
        //    wa.OnGetMessageAudio += wa_OnGetMessageAudio;
        //    wa.OnGetMessageVideo += wa_OnGetMessageVideo;
        //    wa.OnGetMessageLocation += wa_OnGetMessageLocation;
        //    wa.OnGetMessageVcard += wa_OnGetMessageVcard;
        //    wa.OnGetPhoto += wa_OnGetPhoto;
        //    wa.OnGetPhotoPreview += wa_OnGetPhotoPreview;
        //    wa.OnGetGroups += wa_OnGetGroups;
        //    wa.OnGetSyncResult += wa_OnGetSyncResult;
        //    wa.OnGetStatus += wa_OnGetStatus;
        //    wa.OnGetPrivacySettings += wa_OnGetPrivacySettings;
        //    DebugAdapter.Instance.OnPrintDebug += Instance_OnPrintDebug;

        //    wa.Connect();

        //    string datFile = getDatFileName(sender);
        //    byte[] nextChallenge = null;
        //    if (File.Exists(datFile))
        //    {
        //        try
        //        {
        //            string foo = File.ReadAllText(datFile);
        //            nextChallenge = Convert.FromBase64String(foo);
        //        }
        //        catch (Exception) { };
        //    }

        //    wa.Login(nextChallenge);
        //    wa.SendGetServerProperties();

        //    ProcessChat(wa, target);
        //    Console.ReadKey();

        //    wa.SendMessage(sender, "test");
        //    while (true)
        //    {
        //        wa.pollMessage();
        //    }
        //}

        //public static void Main(string[] args)
        //{
        //    var sender = "5521966747230";
        //    var target = ConfigurationManager.AppSettings["destinatario"].ToString();
        //    var nick = "SICADv3";
        //    string imei = ConfigurationManager.AppSettings["base64pwd"].ToString();
        //    string msg = ConfigurationManager.AppSettings["msg"].ToString();

        //    var zapzap = new WhatsApp(sender, imei, nick, false);

        //    zapzap.OnConnectSuccess += () =>
        //    {

        //        Console.WriteLine("Conectado ao zapzap");

        //        zapzap.OnLoginSuccess += (numero, dados) =>
        //        {
        //            zapzap.SendMessage(target, msg);
        //            Console.WriteLine("zap zap enviado...(pressione [ENTER] para finalizar)");
        //            Console.ReadKey();
        //        };


        //        zapzap.OnLoginFailed += (dado) =>
        //        {
        //            Console.WriteLine("Login falhou: {0}", dado);
        //        };

        //        zapzap.Login();
        //    };

        //    zapzap.OnConnectFailed += ex =>
        //    {
        //        Console.WriteLine("deu ruim: {0}", ex.Message);
        //    };
        //    zapzap.Connect();

        //}

        public static void EnviarWhatsapp(string msg, string destinatario)
        {
            var    sender = ConfigurationManager.AppSettings["sender"].ToString();
            string imei   = ConfigurationManager.AppSettings["base64pwd"].ToString();

            if (String.IsNullOrEmpty(sender) || String.IsNullOrEmpty(imei))
            {
                throw new Exception("Algum parâmetro não pode ser lido do arquivo de configuração, ou o mesmo não está presente.");
            }

            var nick   = "JAHU_ZapZap";
            var target = destinatario;
            var zapzap = new WhatsApp(sender, imei, nick, false);

            zapzap.OnConnectSuccess += () =>
            {
                Console.WriteLine("Conectado ao zapzap");

                zapzap.OnLoginSuccess += (numero, dados) =>
                {
                    zapzap.SendMessage(target, msg);
                };

                zapzap.OnLoginFailed += (dado) =>
                {
                    // falha ao logar
                };

                zapzap.Login();
            };

            zapzap.OnConnectFailed += ex =>
            {
                // falha ao conectar.
            };
            zapzap.Connect();
        }
示例#30
0
        private void btMessage_Click(object sender, EventArgs e)
        {
            try
            {
                string from = "94991315204";
                string Fone = txFone.Text;
                string msg  = txMessagem.Text;

                WhatsApp wa = new WhatsApp(from, "snowden+snowden=", "sekhar", false, false);

                wa.OnLoginSuccess += (phoneNumber, data) =>
                {
                    wa.SendMessage(Fone, msg);
                    MessageBox.Show("Messagem Enviada");
                };
                wa.OnLoginFailed += (data) =>
                {
                    MessageBox.Show("login errado:{0}", data);
                };
                wa.Login();
                {
                    wa.OnConnectFailed += (ex) =>
                    {
                        MessageBox.Show("conecçao errada");
                    };

                    {
                        wa.Connect();
                    }
                }
            }

            catch (Exception EX)
            {
                MessageBox.Show(EX.Message);
            }
        }