Aldeamo

EJEMPLOS

Ejemplo A:

Petición GET para obtener los contactos de una campaña con ID 345


Ejemplo B:

Petición POST para crear un contacto con teléfono 3221234123 en la campaña con ID 345

Python

>>> # HTTP GET
USERNAME = "TU_USERNAME"
PASSWORD = "TU_PASSWORD"

>>> # EJEMPLO A
>>> requests.get('https://voz.aldeamo.com/api/campaign/345/contact', auth=(USERNAME, PASSWORD))

>>> # HTTP POST
>>> # EJEMPLO B
>>> requests.post('https://voz.aldeamo.com/api/campaign/345/contact', data={'phone': '3221234123'}, auth=(USERNAME, PASSWORD))

Ejemplos más completos


Jquery AJAX

// HTTP GET
USERNAME = "TU_USERNAME"
PASSWORD = "TU_PASSWORD"

// EJEMPLO A
$.ajax({
    type: "GET",
    url: "https://voz.aldeamo.com/api/campaign/345/contact",
    dataType: 'json',
    beforeSend: function (xhr) {
        xhr.setRequestHeader ("Authorization", "Basic " + btoa(USERNAME + ":" + PASSWORD));
    },
    success: function (data){
        alert('Ok');
    }
});

// HTTP POST
// EJEMPLO B
$.ajax({
    type: "POST",
    url: "https://voz.aldeamo.com/api/campaign/345/contact",
    dataType: 'json',
    data: {phone: "3221234123"},
    beforeSend: function (xhr) {
        xhr.setRequestHeader ("Authorization", "Basic " + btoa(USERNAME + ":" + PASSWORD));
    },
    success: function (data){
        alert('Ok');
    }
});

PHP

// HTTP GET
// EJEMPLO A
<?php

$USERNAME = "TU_USERNAME";
$PASSWORD = "TU_PASSWORD";

$headers = array(
    'Content-Type:application/json',
    'Authorization: Basic '. base64_encode($USERNAME . ":" . $PASSWORD)
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL,"https://voz.aldeamo.com/api/campaign/345/contact");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);

?>

// HTTP POST
// EJEMPLO B
<?php

$headers = array(
    'Content-Type:application/json',
    'Authorization: Basic '. base64_encode($USERNAME . ":" . $PASSWORD)
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL,"https://voz.aldeamo.com/api/campaign/345/contact");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "phone=3221234123");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);

?>