send whatsapp messages using WhatsappAPI in c#

与世无争的帅哥 提交于 2019-12-22 17:52:13

问题


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.


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!