whatsapp c# 身份验证响应错误
本文关键字:错误 响应 身份验证 whatsapp | 更新日期: 2023-09-27 18:32:30
我正在使用whatsapp的最后一个nuget版本: WhastApp API 1.2.2 和阅读有关在我的应用程序中配置我的 whatsapp 的教程。我正在使用我的本地主机进行测试,我的代码是:
string from = "503XXXX";
string to = "503XXXX";
string msg = "lorem ipsum";
WhatsApp wa = new WhatsApp(from, "jd8eY3FXXXXXXXXXXXXXXXXXXX", "MrMins", true);
wa.OnConnectSuccess += () =>
{
wa.OnLoginSuccess += (phoneNumber, data) =>
{
wa.SendMessage(to, msg);
};
};
wa.OnLoginFailed += (data) =>
{
//Fail message
};
wa.Login();
wa.OnConnectFailed += (ex) =>
{
//ConnectionFailed
};
wa.Connect();
wa.SendMessage(to, msg);
wa.Disconnect();
我收到错误:
Auth response error
我用WART更新了我的whatsapp密码,并从我的whatsapp手机中注销了我(我认为这是正确的行为),但仍然不起作用。
我的代码有什么问题?
我想你的问题是,如果连接失败,你也会尝试发送消息。尝试使用以下命令代替代码发送消息:
WhatsApp wa = new WhatsApp("your number", "your password", "your nickname", false, false);
wa.OnConnectSuccess += () =>
{
Response.Write("connect");
wa.OnLoginSuccess += (phno,data) =>
{
wa.SendMessage("to", "msg");
};
wa.OnLoginFailed += (data) =>
{
Response.Write("login failed"+data);
};
wa.Login();
};
wa.OnConnectFailed+= (ex)=>
{
Response.Write("connection failed");
}
这样可以避免在连接失败时发送。
PS:如果在代码中连接成功,您将发送两次消息。
想象一下,你的代码区是:503,你的电话号码是555555555555
WhatsApp wa = new WhatsApp("503555555555555", "get the password using WART", "your nickname", false, false);
wa.OnConnectSuccess += () =>
{
Response.Write("connect");
wa.OnLoginSuccess += (phno,data) =>
{
wa.SendMessage("Destinatino number (50377777777777)", "Youre custom message");
};
wa.OnLoginFailed += (data) =>
{
Response.Write("login failed"+data);
};
wa.Login();
};
wa.OnConnectFailed += (ex) =>
{
Response.Write("connection failed");
}
;
wa.Connect();