|
|
|
|
@ -1,5 +1,4 @@ |
|
|
|
|
using System; |
|
|
|
|
using System.Threading.Tasks; |
|
|
|
|
|
|
|
|
|
using RestSharp; |
|
|
|
|
|
|
|
|
|
namespace n4_whatsapi |
|
|
|
|
@ -9,6 +8,9 @@ namespace n4_whatsapi |
|
|
|
|
static void Main(string[] args) |
|
|
|
|
{ |
|
|
|
|
Program.SendMessage().Wait(); |
|
|
|
|
Program.SendMessageWithImage().Wait(); |
|
|
|
|
Program.SendMessageWithVideo().Wait(); |
|
|
|
|
Program.SendMessageWithFile().Wait(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static async Task SendMessage() |
|
|
|
|
@ -23,5 +25,44 @@ namespace n4_whatsapi |
|
|
|
|
var output = reponse.Content; |
|
|
|
|
Console.WriteLine(output); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static async Task SendMessageWithImage() |
|
|
|
|
{ |
|
|
|
|
var whatsapiURL = "https://whatsapi.nube4.cloud/whatsapi/img"; |
|
|
|
|
var client = new RestClient(whatsapiURL); |
|
|
|
|
|
|
|
|
|
var request = new RestRequest(whatsapiURL, Method.Post); |
|
|
|
|
request.AddBody("{\"instanceid\":\"instance14116\", \"token\":\"r3gkujuqh8erl340\", \"to\":\"+50258797957\", \"imageurl\":\"https://resources.nube4.cloud/wifi.jpg\", \"caption\":\"Imagen de prueba\" }"); |
|
|
|
|
|
|
|
|
|
RestResponse reponse = await client.ExecuteAsync(request); |
|
|
|
|
var output = reponse.Content; |
|
|
|
|
Console.WriteLine(output); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static async Task SendMessageWithVideo() |
|
|
|
|
{ |
|
|
|
|
var whatsapiURL = "https://whatsapi.nube4.cloud/whatsapi/video"; |
|
|
|
|
var client = new RestClient(whatsapiURL); |
|
|
|
|
|
|
|
|
|
var request = new RestRequest(whatsapiURL, Method.Post); |
|
|
|
|
request.AddBody("{\"instanceid\":\"instance14116\", \"token\":\"r3gkujuqh8erl340\", \"to\":\"+50258797957\", \"videourl\":\"https://resources.nube4.cloud/test.mov\", \"caption\":\"Video de prueba\" }"); |
|
|
|
|
|
|
|
|
|
RestResponse reponse = await client.ExecuteAsync(request); |
|
|
|
|
var output = reponse.Content; |
|
|
|
|
Console.WriteLine(output); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static async Task SendMessageWithFile() |
|
|
|
|
{ |
|
|
|
|
var whatsapiURL = "https://whatsapi.nube4.cloud/whatsapi/doc"; |
|
|
|
|
var client = new RestClient(whatsapiURL); |
|
|
|
|
|
|
|
|
|
var request = new RestRequest(whatsapiURL, Method.Post); |
|
|
|
|
request.AddBody("{\"instanceid\":\"instance14116\", \"token\":\"r3gkujuqh8erl340\", \"to\":\"+50258797957\", \"filename\":\"Prueba.pdf\",\"documenturl\":\"https://resources.nube4.cloud/test.pdf\", \"caption\":\"Documento adjunto\" }"); |
|
|
|
|
|
|
|
|
|
RestResponse reponse = await client.ExecuteAsync(request); |
|
|
|
|
var output = reponse.Content; |
|
|
|
|
Console.WriteLine(output); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |