我写的代码发送短信使用whatsapp API和winform C#.我不知道它有什么问题.
它有错误
“登录失败未授权”
...但我注册在“WhatsApp注册”下载从“https://github.com/mgp25/WART“和密码一样的图像.
这是我的代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WhatsAppApi;
namespace sms
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btn_send_Click(object sender, EventArgs e)
{
WhatsApp wa = new WhatsApp(txt_phone.Text, txt_pass.Text, txt_name.Text, true);
wa.OnConnectSuccess+= () =>
{
txt_status.Text = "Connect...";
wa.OnLoginSuccess+= (phone, data) =>
{
txt_status.Text += "\r\nConnection success!";
wa.SendMessage(txt_to.Text, txt_message.Text);
txt_status.Text += "\r\nMessage Sent!";
};
wa.OnLoginFailed+= (data) =>
{
txt_status.Text += string.Format("\r\bLogin failed {0}", data);
};
wa.Login();
};
wa.OnConnectFailed+= (ex) =>
{
txt_status.Text += string.Format("\r\bConnect failed {0}", ex.StackTrace);
};
wa.Connect();
}
}
}
1条答案
按热度按时间qhhrdooz1#
试试这个:
有了这个代码,你可以发送短信没有问题。
祝你好运