我正在使用this API来连接&发送消息给Whatsapp。这是代码。
WhatsApp wa = new WhatsApp("your number", "your password", "Name", 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");
}
wa.Connect();
wa.Disconnect();
但是这条线
wa.Login();
wa.Disconnect();
我收到错误
No overload for method 'Login' takes '0' arguments
我已经阅读了几个教程,但没有一个在login方法中使用任何参数。如何解决这个问题?
答案 0 :(得分:1)
这对我来说很好
WhatsUserManager manager = new WhatsUserManager();
user = manager.CreateUser(txtphonenumber.Text, "NAME");
var thread = new Thread(ThreadState =>
{
UpdateTextBox textbox = UpdateDataTextBox;
WhatSocket.Create(txtphonenumber.Text, textBoxPass.Text, textBoxNick.Text, true);
WhatSocket.Instance.OnConnectSuccess += () =>
{
if (txtstatus.InvokeRequired)
{
Invoke(textbox, txtstatus, "connected...");
}
WhatSocket.Instance.OnLoginSuccess += (phone, data) =>
{
//WhatSocket.Instance.PollMessages(true);
WhatSocket.Instance.SendMessage("SENDER_NUMBER", "TEST");
Invoke(textbox, txtstatus, "Login Success...");
};
WhatSocket.Instance.OnLoginFailed += (data) =>
{
if (txtstatus.InvokeRequired)
{
Invoke(textbox, txtstatus, string.Format("\r\n Login Failed : {0}", data));
}
};
WhatSocket.Instance.OnGetMessage += (node,from,id,name,message,receipt_sent) =>
{
Invoke(textbox, txtstatus, string.Format("\r\n Name : {0}, Message : {1}", name,message));
};
WhatSocket.Instance.Login();
};
WhatSocket.Instance.OnConnectFailed += (ex) =>
{
if (txtstatus.InvokeRequired)
{
Invoke(textbox, txtstatus, string.Format("\r\n Connect Failed : {0}", ex.StackTrace));
}
};
WhatSocket.Instance.Connect();
}) { IsBackground = true };
thread.Start();