WhatsUserManager manager = new WhatsUserManager();
user = manager.CreateUser(txtphonenumber.Text, "Bhavdip Tala");
var thread = new Thread(ThreadState =>
{
UpdateTextBox textbox = UpdateDataTextBox;
WhatSocket.Create(txtphonenumber.Text, textBoxPass.Text, textBoxNick.Text, true);
WhatSocket.Instance.OnConnectSuccess += () =>
{
if (txtstatus.InvokeRequired)
{
Invoke(textbox, txtstatus, "connected...");
}
WhatSocket.Instance.OnLoginSuccess += (phone, data) =>
{
Invoke(textbox, txtstatus, "Login Success...");
//WhatSocket.Instance.SendDeleteAccount();
while (WhatSocket.Instance != null)
{
WhatSocket.Instance.pollMessage();
Thread.Sleep(200);
continue;
}
};
WhatSocket.Instance.OnGetMessage += (node, from, id, name, message, receipt_sent) =>
{
if (txtstatus.InvokeRequired)
{
string[] words = from.Split('@');
if (WhatSocket.Instance.ConnectionStatus == ApiBase.CONNECTION_STATUS.LOGGEDIN)
{
if (message.ToString().ToUpper().Contains("IMG"))
{
byte[] img = File.ReadAllBytes(@"D:\P1.Jpg");
WhatSocket.Instance.SendMessageImage(words[0] + "@s.whatsapp.net", img, ApiBase.ImageType.JPEG);
}
else if (message.ToString().ToUpper().Contains("VID"))
{
byte[] img = File.ReadAllBytes(@"D:\EMERALD.mp4");
WhatSocket.Instance.SendMessageVideo(words[0] + "@s.whatsapp.net", img, ApiBase.VideoType.MP4);
}
else
{
Invoke(textbox, txtstatus, string.Format("\r\n {0}:{1}", name + " : " + words[0], message));
}
}
}
};
WhatSocket.Instance.OnLoginFailed += (data) =>
{
if (txtstatus.InvokeRequired)
{
Invoke(textbox, txtstatus, string.Format("\r\n Login Failed : {0}", data));
}
};
WhatSocket.Instance.Login();
};
WhatSocket.Instance.OnConnectFailed += (ex) =>
{
if (txtstatus.InvokeRequired)
{
Invoke(textbox, txtstatus, string.Format("\r\n Connect Failed : {0}", ex.StackTrace));
}
};
WhatSocket.Instance.Connect();
}) { IsBackground = true };
thread.Start();
user = manager.CreateUser(txtphonenumber.Text, "Bhavdip Tala");
var thread = new Thread(ThreadState =>
{
UpdateTextBox textbox = UpdateDataTextBox;
WhatSocket.Create(txtphonenumber.Text, textBoxPass.Text, textBoxNick.Text, true);
WhatSocket.Instance.OnConnectSuccess += () =>
{
if (txtstatus.InvokeRequired)
{
Invoke(textbox, txtstatus, "connected...");
}
WhatSocket.Instance.OnLoginSuccess += (phone, data) =>
{
Invoke(textbox, txtstatus, "Login Success...");
//WhatSocket.Instance.SendDeleteAccount();
while (WhatSocket.Instance != null)
{
WhatSocket.Instance.pollMessage();
Thread.Sleep(200);
continue;
}
};
WhatSocket.Instance.OnGetMessage += (node, from, id, name, message, receipt_sent) =>
{
if (txtstatus.InvokeRequired)
{
string[] words = from.Split('@');
if (WhatSocket.Instance.ConnectionStatus == ApiBase.CONNECTION_STATUS.LOGGEDIN)
{
if (message.ToString().ToUpper().Contains("IMG"))
{
byte[] img = File.ReadAllBytes(@"D:\P1.Jpg");
WhatSocket.Instance.SendMessageImage(words[0] + "@s.whatsapp.net", img, ApiBase.ImageType.JPEG);
}
else if (message.ToString().ToUpper().Contains("VID"))
{
byte[] img = File.ReadAllBytes(@"D:\EMERALD.mp4");
WhatSocket.Instance.SendMessageVideo(words[0] + "@s.whatsapp.net", img, ApiBase.VideoType.MP4);
}
else
{
Invoke(textbox, txtstatus, string.Format("\r\n {0}:{1}", name + " : " + words[0], message));
}
}
}
};
WhatSocket.Instance.OnLoginFailed += (data) =>
{
if (txtstatus.InvokeRequired)
{
Invoke(textbox, txtstatus, string.Format("\r\n Login Failed : {0}", data));
}
};
WhatSocket.Instance.Login();
};
WhatSocket.Instance.OnConnectFailed += (ex) =>
{
if (txtstatus.InvokeRequired)
{
Invoke(textbox, txtstatus, string.Format("\r\n Connect Failed : {0}", ex.StackTrace));
}
};
WhatSocket.Instance.Connect();
}) { IsBackground = true };
thread.Start();
9 Comments
HI
ReplyDeleteI also tried the code as mentioned in your blog but still the images are not going.below is the code what i have used. can you tell me whats is wrong in the code. Please help me
WhatsApp wa;
wa = new WhatsApp(mobileno, pwd, "demo");
wa.Connect();
wa.Login();
byte[] img = File.ReadAllBytes(@"C:\Users\Public\Pictures\Sample Pictures\Desert.jpg");
wa.SendMessageImage(txtto.text & '@s.whatsapp.net",img,ApiBase.ImageType.JPEG);
Please help me.
wa = new WhatsApp(mobileno, pwd, "demo");
DeleteChange as like below
wa = new WhatsApp(91978xxxx49, WART Generated Password, "User Name");
i have put link,demo code plz check it
DeleteVery Excellent Work !!!
ReplyDeleteKindly provide vb.net Version ...
ReplyDeleteI have used converter but i'm strucked.
I tried to upload video but video is sent to target number and when user try to download it gives error The download was unable to complete. Please try again later.
ReplyDeleteKindly guide.
http://bhavdiptala.blogspot.in/2015/10/demo-code-send-video-in-whatsapp-using-c.html
DeleteThank you very much. It is working very fine with mp4 and mov files but in avi files video not able to download. Getting error "The download was unable to complete. Please try again later."
DeleteCan someone please share their application with me?
ReplyDelete