I have designed a window form to send whatsApp msg and wrote the following code to WhatsApp in Pakistan
after that I am trying to get the Password by using the WART-1.8.2.2. When I execute this file and try to connect it. It is showing me following message. how to fix it and get solution to WhatsApp anywhere all around the world or at least in Pakistan. Error screenshot is attached..
using WhatsAppApi;
using WhatsAppApi.Account;
namespace AB
{
public partial class frmWhatsApp : Form
{
WhatsApp wa;
WhatsAppApi.Account.WhatsUser user;
public frmWhatsApp()
{
InitializeComponent();
}
private delegate void updateTextBox(TextBox textbox, string value);
public void UpdateDataTextBox(TextBox textbox, string value)
{
textbox.Text += value;
}
private void frmWhatsApp_Load(object sender, EventArgs e)
{
}
private void btnSend_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtSMS.Text))
return;
if (wa != null)
{
if (wa.ConnectionStatus == ApiBase.CONNECTION_STATUS.LOGGEDIN)
{
wa.SendMessage(txtTo.Text, txtSMS.Text);
txtStatus.Text += string.Format("\r\n{0}:{1}", user.Nickname, txtSMS.Text);
txtSMS.Clear();
txtSMS.Focus();
}
}
}
private void btnLogin_Click(object sender, EventArgs e)
{
WhatsUserManager manager = new WhatsUserManager();
user = manager.CreateUser(txtPhone.Text, txtName.Text);
var thread = new Thread(t =>
{
updateTextBox textbox = UpdateDataTextBox;
wa = new WhatsApp(txtPhone.Text, txtPass.Text, txtName.Text, true);
wa.OnConnectSuccess += () =>
{
if (txtStatus.InvokeRequired)
Invoke(textbox, txtStatus, "Connected Success.ok");
wa.OnLoginSuccess += (phone, data) =>
{
if (txtStatus.InvokeRequired)
Invoke(textbox, txtStatus, "Login Success.ok");
while (wa != null)
{
wa.pollMessage();
Thread.Sleep(200);
continue;
}
};
wa.OnGetMessage += (node, from, id, name, message, receipt_sent) =>
{
if (txtStatus.InvokeRequired)
Invoke(textbox, txtStatus, string.Format("\r\n{0}:{1}", name, message));
};
wa.OnLoginFailed += (data) =>
{
if (txtStatus.InvokeRequired)
Invoke(textbox, txtStatus, string.Format("\r\n Login Failed {0}", data));
};
wa.Login();
};
wa.OnConnectFailed += (ex) =>
Invoke(textbox, txtStatus, string.Format("\r\n Connect Failed {0}", ex.StackTrace));
wa.Connect();
}) { IsBackground = true };
thread.Start();
}
private void btnTest_Click(object sender, EventArgs e)
{
WhatsApp wa = new WhatsApp(txtPhone.Text, txtPass.Text, txtName.Text, true);
wa.OnConnectSuccess += () =>
{
txtStatus.Text = "Connected";
wa.OnLoginSuccess += (phone, data) =>
{
txtStatus.Text += "\r\n Connection Success";
wa.SendMessage(txtTo.Text, txtSMS.Text);
txtStatus.Text += "\r\n Message Sent";
};
wa.OnLoginFailed += (data) =>
{
txtStatus.Text += string.Format("\r\n Login Failed {0}", data);
};
wa.Login();
};
wa.OnConnectFailed += (ex) =>
{
txtStatus.Text += string.Format("\r\n Connect Failed {0}", ex.StackTrace);
};
}
}
}
how to get the code in better way????