Code request
# También puede usar wget
curl -X POST "https://www.onurix.com/api/v1/whatsapp/send" -d client=AQUI_SU_KEY -d key=AQUI_SU_CLIENT -d template-id=AQUI_EL_ID_DE_LA_PLANTILLA" -H 'Content-Type: application/json' -d 'AQUI_EL_JSON_CON_LOS_VALORES_PARA_LA_PLANTILLA'
Code request
<?php
// Ejecutar: composer require guzzlehttp/guzzle:*
require'vendor/autoload.php';
$clientId = "AQUI_SU_CLIENT";
$key = "AQUI_SU_KEY";
$templateId = "AQUI_EL_ID_DE_LA_PLANTILLA";
$client = new \GuzzleHttp\Client();
$headers = [
'Content-Type' => 'application/json'
];
$data = 'AQUI_EL_ARREGLO_CON_LOS_VALORES_PARA_LA_PLANTILLA';
$response = $client->post("https://www.onurix.com/api/v1/whatsapp/send?key=$key&client=$clientId&templateId=$templateId",['body' => json_encode($data)]);
echo $response->getBody()->getContents();
Code request
import requests
import json
url = "https://www.onurix.com/api/v1/whatsapp/send?key=AQUI_SU_KEY&client=AQUI_SU_CLIENT&templateId=AQUI_EL_ID_DE_LA_PLANTILLA"
payload = json.dumps('AQUI_EL_JSON_CON_LOS_VALORES_PARA_LA_PLANTILLA')
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Code request
//Este codigo fue hecho en .net 6
using System.Text;
using System.Net.Http;
namespace PruebaOnurix
{
public class Program
{
public static void Main(string[] args)
{
WhatsAppSend();
}
public static void WhatsAppSend()
{
string key = "AQUI_SU_KEY";
string client = "AQUI_SU_CLIENT";
string templateId = "AQUI_EL_ID_DE_LA_PLANTILLA";
string parameters = "AQUI_EL_JSON_CON_LOS_VALORES_PARA_LA_PLANTILLA"
using var httpClient = new HttpClient()
{
BaseAddress = new Uri("https://www.onurix.com/"),
};
HttpResponseMessage request = httpClient.PostAsync($"api/v1/whatsapp/send?client={client}&key={key}&templateId={templateId}", content: new StringContent(parameters, Encoding.UTF8, "application/json")).Result;
string responseString = request.Content.ReadAsStringAsync().Result;
Console.WriteLine(responseString);
}
}
}
Code request
package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
url := "https://www.onurix.com/api/v1/whatsapp/send?key=AQUI_SU_KEY&client=AQUI_SU_CLIENT&templateId=AQUI_EL_ID_DE_LA_PLANTILLA"
method := "POST"
payload := strings.NewReader(`AQUI_EL_JSON_CON_LOS_VALORES_PARA_LA_PLANTILLA`)
client := &http.Client{}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "text/plain")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}
Code request
// Ejecutar: npm install axios --save
const axios = require('axios').default;
let headers = {headers:
{ 'Content-Type': 'application/json'}
};
// data = JSON.stringify({
// "phone": "+573201234567",
// "body": [
// "Parametro1",
// "Parametro2"
// ]
// })
let data= JSON.stringify('AQUI_EL_JSON_CON_LOS_VALORES_PARA_LA_PLANTILLA')
axios.post('https://www.onurix.com/api/v1/whatsapp/send?key=AQUI_SU_KEY&client=AQUI_SU_CLIENT&templateId=AQUI_EL_ID_DE_LA_PLANTILLA',data,headers)
.then(resp=>{
console.log(resp.data);
}).catch(error=>{
console.log(error);
});
Code request
//Para este codigo se uso jdk 11
import java.io.IOException;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
public class WhatsAppGeneralSend {
public static void main(String[] args) throws IOException, InterruptedException {
// TODO Auto-generated method stub
String clientId = "AQUI_SU_CLIENT";
String key = "AQUI_SU_KEY";
String templateId = "AQUI_EL_ID_DE_LA_PLANTILLA";
var httpClient = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder()
.version(HttpClient.Version.HTTP_2)
.POST(HttpRequest.BodyPublishers.ofString("AQUI_EL_JSON_CON_LOS_VALORES_PARA_LA_PLANTILLA"))
.uri(URI.create("https://www.onurix.com/api/v1/whatsapp/send?client=" + clientId + "&key=" + key + "&templateId=" + templateId))
.header("Content-Type", "application/json")
.build();
var response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}
Url parameters
client : 0,
key : "string",
templateId : "string"
Body parameters example
{
"phones": "string",
"header": {
1: {
"type": "text",
"value": "string"
}
},
"body": {
1: {
"type": "text",
"value": "string"
}
},
"button": {
1: {
"type": "text",
"value": "string"
}
}
}
Respuesta de ejemplo
Response 200
{
"id": "string",
"status": "string",
"phone": "string",
"name": "string"
}