I have installed WhatsappAPI from nuGet package manager and tried to implement code but could not register my mobile number through WART(WhatsApp Registration Tool)
.Its giving error LIKE {Status:"Failed",Reason:"Bad_Request"}
all the time.
I have searched a lot.But there is no any solution to this issue.
There is only tool i.e. WART for registration.
Is there any new updates
OR WART is still working
..??
My code is given below.
public JsonResult SendMessage(string sendTo,string message)
{
var response = false;
string from = "91XXXXXXXXXX"; //(Enter Your Mobile Number)
String password;
var res = WhatsAppApi.Register.WhatsRegisterV2.RequestCode(from, out password);
WhatsApp wa = new WhatsApp(from, password, "abc.com", false, false);
wa.OnConnectSuccess += () =>
{
wa.OnLoginSuccess += (phonenumber, data) =>
{
wa.SendMessage(sendTo, message);
response = true;
};
wa.OnLoginFailed += (data) =>
{
response = false;
};
wa.Login();
};
wa.OnConnectFailed += (Exception) =>
{
response = false;
};
return Json(response);
}
In above code m not able to generate password through WART tool or not by using api CodeRequest method.
Let me know if any updates is there.
Before all, you should prepare a new number that not registered in whatsapp, and then do following steps to get password.
string password ;
string number = "xxxx";
WhatsAppApi.Register.WhatsRegisterV2.RequestCode(number , out password);
//you will recieve a sms, use it to get password
string password =WhatsAppApi.Register.WhatsRegisterV2.RegisterCode(number ,"code from sms");
And the config of library is old, you should do a new configuration.
来源:https://stackoverflow.com/questions/44984982/send-whatsapp-messages-using-whatsappapi-in-c-sharp