简体   繁体   中英

how to send WhatsApp message using WhatsApp API only in C#(should not use any third-party API links)

How to send WhatsApp Message using WhatsApp API only (should not use any third-party API links Ex: Twilio API, WART Tool WhatsApp....)

I searched in google but I didn't find any solution for this can you please tell me is there any way to send WhatsApp Message without using any third-party API links)

Sorry for my bad English.

use this tool: https://curl.olsh.me/ and copy the code of the test-message you get on YourMeatapp -> WhatsApp -> First steps -> send test message. result ie

using (var httpClient = new HttpClient())
{
    using (var request = new HttpRequestMessage(new HttpMethod("POST"), "https://graph.facebook.com/v14.0/[Your telephoneNumberId]/messages"))
    {
        reques]"); 

        request.Content = new StringContent("{ \"messaging_product\": \"whatsapp\", \"to\": \"[NumberToSend]\", \"type\": \"template\", \"template\": { \"name\": \"hello_world\", \"language\": { \"code\": \"en_US\" } } }");
        request.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); 

        var response = await httpClient.SendAsync(request);
    }
}

replace the content between [] with your values.

If you only want to send a text message change the line requst.Content =... to:

String whatsAppContent = "";
        whatsAppContent += "\"messaging_product\": \"whatsapp\",";
        whatsAppContent += " \"recipient_type\":\"individual\",";
        whatsAppContent += " \"to\": \"[NumberToSend]\",";
        whatsAppContent += " \"type\": \"text\",";
        whatsAppContent += " \"text\": {\"preview_url\": false,\"body\": \" " + "Your message"+ "\"}";

request.Content = new StringContent("{" + whatsAppContent + "}");

kind regards

Ottilie

You can either use WhatsApp's Official APIs or npm packages like waeasyapi or similar to send messages.

WhatsApp only allows official business numbers to send and receive messages using APIs. Either way, you'll have to pay to use APIs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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