Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
149 views
in Technique[技术] by (71.8m points)

c# - Send messages with whatsapi.net?

I want to send messages using whatsapi and this was my try

string nickname = "Test";
string sender = "xxxxxxxxxxxxxx";         
//My Phone Number tryed with 049xxxxxxxxxxxx, 0049xxxxxxxxxxxxxx, 49xxxxxxxxxxxxxxx, xxxxxxxxxxxxxx
string imei = "xxxxxxxxxxxxxxxxxxxxxxxxx";//My IMEI 
WhatsApp me = new WhatsApp(sender,imei ,nickname,true);
me.Connect();
Console.WriteLine(me.ConnectionStatus);// I get a Connection!
Console.ReadLine();
me.SendMessage("xxxxxxxxxx", "This is a Test!");// Send Message
//No Message received :(
me.Disconnect();
Console.WriteLine(me.ConnectionStatus);
Console.ReadLine();

Now where is my mistake? and how I'm doing it right?

I'm using this version: https://github.com/perezdidac/WhatsAPINet.

First I just want to send messages. When I try to get a request from the WART, I just get this message:

Could not request code using either sms or voice.
SMS: {"status":"fail","reason":"no routes","retry_after": 3600}
Voice: {"status":"fail","reason":"no routes","retry_after": 3600}
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
    WhatsApp wa = new WhatsApp("your number", "your password", "pankaj", 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");
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...