简体   繁体   English

如何从WhatsApp C#API发送图像

[英]how to send image from whatsapp C# api

I am not getting how to send image to any number using WhatsApiNet ? 我没有如何使用WhatsApiNet将图像发送到任何号码?

case "/image":
byte[] imgData = File.ReadAllBytes(@"d:\My Creations\DSC_0423 copy.jpg");
wa.SendMessageImage(tmpUser.GetFullJid(), imgData, ApiBase.ImageType.JPEG);
break;!

But its not working.. 但它不起作用..

I too was facing the same problem, fortunately I got the solution :) 我也面临着同样的问题,幸运的是我得到了解决方案:)

byte[] img = File.ReadAllBytes("e:\\img.gif");
wa.OnConnectSuccess += () =>
{
      MessageBox.Show("Connected to whatsapp...");

      wa.OnLoginSuccess += (phoneNumber, data) =>
      {
          wa.SendMessage(to, msg);

          wa.SendMessageImage(to + "@s.whatsapp.net",img,ApiBase.ImageType.GIF);
          MessageBox.Show("Message Sent...");
      };
}

You will just need to modify only 1 line in your code. 您只需要在代码中修改1行即可。

wa.SendMessageImage(tmpUser.GetFullJid()+ "@s.whatsapp.net", imgData, ApiBase.ImageType.JPEG);

Hop this will help others too :D Hav a Nyc day :) 希望这也会对其他人有所帮助:D Hv Nyc day :)

See: Is it legal to use WhatsAPI? 请参阅: 使用WhatsAPI是否合法?

There seems to be an indication of ongoing legal issues between WhatsApp and the creator of the API open-source project. WhatsApp与API开源项目的创建者之间似乎存在持续的法律问题。

There's also mention that WhatsApp have changed some of the details around authentication, so it may be the case that you can't send the message simply because WhatsApp have stopped allowing access. 还提到了WhatsApp已更改了有关身份验证的一些详细信息,因此,可能是因为WhatsApp已停止允许访问而无法发送消息的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM