whatsapp c#验证响应错误

时间:2016-01-28 20:37:44

标签: c# whatsapp

我使用whatsapp的最后一个nuget版本:  WhastApp API 1.2.2并阅读有关在我的应用程序中配置我的whatsapp的教程。 我使用我的localhost进行测试,我的代码是:

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手机中注销(我认为这是正确的行为),但仍无效。

我的代码出了什么问题?

2 个答案:

答案 0 :(得分:1)

我想您的问题是,如果连接失败,您也会尝试发送消息。尝试使用此代码而不是代码来发送消息:

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:如果在您的代码中连接成功,您将发送消息两次。

答案 1 :(得分:1)

想象一下,您的代码区域是: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();