|
Prossima revisione
|
Revisione precedente
|
documentazione_api [2020/09/19 12:40] hydrasolutions creata |
documentazione_api [2020/09/22 18:11] (versione attuale) enterprise |
| Documentazione API | ====== Sindaci in Contatto Documentazione API v0.1 ====== |
| | |
| | **Introduzione ** |
| | |
| | L’accesso all’endpoint delle API del sistema Sindaci in Contatto, permette di usufruire di diverse funzionalità, usualmente presenti sul pannello web, tramite qualsiasi dispositivo o applicativo che ne faccia richiesta usando chiamate su protocollo HTTPS. |
| | |
| | L’ endpoint primario è raggiungibile al seguente URL: |
| | |
| | [[https://api.sindacincontatto.it|https://api.sindacincontatto.it]] |
| | |
| | L’architettura API segue le linee guida RESTful (Representational State Transfer) |
| | |
| | Le chiamate alle API dovranno avvenire tramite cURL con trasmissione di un oggetto JSON contenente dei parametri specifici per ogni nodo. Tali parametri sono definiti dettagliatamente nelle rispettive sezioni. |
| | |
| | ===== Ambito campagne chiamate vocali ===== |
| | |
| | Funzionalità disponibili: |
| | |
| | * Elenco campagne create |
| | * Dettaglio campagne create |
| | |
| | ==== Elenco campagne create ==== |
| | |
| | Restituisce l’elenco degli id di campagne di chiamate automatizzate dello specifico utente che ne ha fatto richiesta. |
| | |
| | End Point: [[https://api.sindacincontatto.it/campaign/list|https://api.sindacincontatto.it/campaign/list]] |
| | |
| | Parametri JSON: |
| | |
| | * username: il proprio username |
| | * password: la propria password |
| | |
| | esempio formattazione: {“username”:”mia_user”,”password”:”mia_password”} |
| | |
| | **Esempio di codice CURL: ** |
| | <code> |
| | |
| | curl -X POST https://api.sindacincontatto.it/campaign/list |
| | -H "Content-Type: application/json" |
| | -d '{"username":" mia_user ","password":" mia_password"}' |
| | |
| | </code> |
| | |
| | **Esempio di codice PHP:** |
| | |
| | <code> |
| | $url = "https://api.sindacincontatto.it/campaign/list"; |
| | |
| | $curl = curl_init($url); |
| | curl_setopt($curl, CURLOPT_URL, $url); |
| | curl_setopt($curl, CURLOPT_POST, true);; |
| | curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
| | |
| | $headers = array(); |
| | $headers["Content-Type"] = "application/json"; |
| | |
| | curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); |
| | |
| | $data = '{"username":"mia_user","password":"mia_password"}'; |
| | |
| | curl_setopt($curl, CURLOPT_POSTFIELDS, $data); |
| | |
| | //for debug only! |
| | curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); |
| | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); |
| | |
| | $resp = curl_exec($curl); |
| | curl_close($curl); |
| | var_dump($resp); |
| | |
| | </code> |
| | |
| | **Esempio javascript/ajax** |
| | |
| | <code> |
| | var url = "https://api.sindacincontatto.it/campaign/list"; |
| | |
| | var xhr = new XMLHttpRequest(); |
| | xhr.open("POST", url); |
| | |
| | xhr.setRequestHeader("Content-Type", "application/json"); |
| | |
| | xhr.onreadystatechange = function () { |
| | if (xhr.readyState === 4) { |
| | console.log(xhr.status); |
| | console.log(xhr.responseText); |
| | }}; |
| | |
| | var data = '{"username":"mia_user","password":"mia_password"}'; |
| | |
| | xhr.send(data); |
| | |
| | </code> |
| | |
| | // // |
| | |
| | ==== Risposte: ==== |
| | |
| | === Risposta corretta: === |
| | |
| | <code> |
| | { |
| | "response": "OK", |
| | "data": [ |
| | { |
| | "id_campagna": "1", |
| | "nome_campagna": "Campagna1", |
| | "data_attivazione": "2017-06-06 11:14:33" |
| | }, |
| | { |
| | "id_campagna": "2", |
| | "nome_campagna": "Campagna2", |
| | "data_attivazione": "2017-10-04 17:12:28" |
| | }, |
| | } |
| | |
| | </code> |
| | |
| | **Errore di autenticazione:** |
| | |
| | <code> |
| | { |
| | "result": "KO", |
| | "mgs": "problema di autenticazione" |
| | } |
| | |
| | </code> |
| | |
| | // // |
| | |
| | ==== Dettaglio campagne create ==== |
| | |
| | //Restituisce l’elenco degli id di campagne di chiamate automatizzate dello specifico utente che ne ha fatto richiesta. End Point: [[https://api.sindacincontatto.it/campaign/detail/<id_campagna|https://api.sindacincontatto.it/campaign/detail/<id_campagna]]> Nodo specifico: <id_campagna> : id della campagna di cui si desidera ricevere le informazioni di dettaglio Parametri JSON: • username: il proprio username • password: la propria password esempio formattazione: {“username”:”mia_user”,”password”:”mia_password”} Esempio di codice CURL: curl -X POST [[https://api.sindacincontatto.it/campaign/detail/1|https://api.sindacincontatto.it/campaign/detail/1]] -H "Content-Type: application/json" -d '{"username":" mia_user ","password":" mia_password"}' // |
| | |
| | //Esempio di codice PHP: // |
| | |
| | //<?php $url = "https://api.sindacincontatto.it/campaign/detail/1"; |
| | |
| | $curl = curl_init($url); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, true);; curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
| | |
| | $headers = array(); $headers["Content-Type"] = "application/json"; |
| | |
| | curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); |
| | |
| | $data = '{"username":"mia_user","password":"mia_password"}'; |
| | |
| | curl_setopt($curl, CURLOPT_POSTFIELDS, $data); |
| | |
| | //for debug only! curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $resp = curl_exec($curl); curl_close($curl); var_dump($resp); ?> Esempio javascript/ajax var url = "https://api.sindacincontatto.it/campaign/detail/1"; |
| | |
| | var xhr = new XMLHttpRequest(); xhr.open("POST", url); |
| | |
| | xhr.setRequestHeader("Content-Type", "application/json"); |
| | |
| | xhr.onreadystatechange = function () { |
| | <code> |
| | |
| | if (xhr.readyState === 4) { |
| | console.log(xhr.status); |
| | console.log(xhr.responseText); |
| | }}; |
| | |
| | </code> |
| | |
| | var data = '{"username":"mia_user","password":"mia_password"}'; |
| | |
| | xhr.send(data); |
| | |
| | Risposte: |
| | |
| | Risposta corretta: { |
| | |
| | <code> |
| | "result": "OK", |
| | "data": { |
| | "dettagli_campagna": { |
| | "nome_campagna": "Campagna 1 ", |
| | "stato_campagna": "PAUSE", |
| | "data_attivazione": "2017-05-11 21:44:45" |
| | }, |
| | "report": { |
| | "tot_lista": 1000, |
| | "contattati": 1000, |
| | "risposte": 869 |
| | } |
| | } |
| | |
| | </code> |
| | |
| | } |
| | |
| | Errore di autenticazione: { |
| | |
| | <code> |
| | "result": "KO", |
| | "mgs": "problema di autenticazione" |
| | |
| | </code> |
| | |
| | } |
| | |
| | ===== Ambito campagne SMS ===== |
| | |
| | Funzionalità disponibili: |
| | |
| | * Elenco campagne create |
| | * Dettaglio campagne create |
| | |
| | Elenco campagne create |
| | |
| | Restituisce l’elenco degli id di campagne di SMS automatizzate dello specifico utente che ne ha fatto richiesta. |
| | |
| | End Point: [[https://api.sindacincontatto.it/sms_campaign/list|https://api.sindacincontatto.it/sms_campaign/list]] |
| | |
| | Parametri JSON: • username: il proprio username • password: la propria password |
| | |
| | esempio formattazione: {“username”:”mia_user”,”password”:”mia_password”} |
| | |
| | Esempio di codice CURL: curl -X POST [[https://api.sindacincontatto.it/sms_campaign/list|https://api.sindacincontatto.it/sms_campaign/list]] |
| | <code> |
| | |
| | -H "Content-Type: application/json" |
| | -d '{"username":" mia_user ","password":" mia_password"}' |
| | |
| | </code> |
| | |
| | Esempio di codice PHP: |
| | |
| | <?php $url = "https://api.sindacincontatto.it/sms_campaign/list"; $curl = curl_init($url); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, true);; curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $headers = array(); $headers["Content-Type"] = "application/json"; curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); $data = '{"username":"mia_user","password":"mia_password"}'; curl_setopt($curl, CURLOPT_POSTFIELDS, $data); //for debug only! curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); |
| | |
| | $resp = curl_exec($curl); curl_close($curl); var_dump($resp); |
| | |
| | ?> |
| | |
| | Esempio javascript/ajax |
| | |
| | var url = "https://api.sindacincontatto.it/sms_campaign/list"; var xhr = new XMLHttpRequest(); xhr.open("POST", url); xhr.setRequestHeader("Content-Type", "application/json"); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { console.log(xhr.status); console.log(xhr.responseText); }}; var data = '{"username":"mia_user","password":"mia_password"}'; xhr.send(data); Risposte: Risposta corretta: { "response": "OK", "data": [ { "id_campagna": "1", "nome_campagna": "Campagna SMS 1", "data_attivazione": "2017-06-06 11:14:33" }, { "id_campagna": "2", "nome_campagna": "Campagna SMS 2", "data_attivazione": "2017-10-04 17:12:28" }, } Errore di autenticazione: { "result": "KO", "mgs": "problema di autenticazione" } // |
| | |
| | //Dettaglio campagne create // |
| | |
| | //Restituisce l’elenco degli id di campagne di chiamate automatizzate dello specifico utente che ne ha fatto richiesta. // |
| | |
| | //End Point: [[https://api.sindacincontatto.it/sms_campaign/detail/<id_campagna|https://api.sindacincontatto.it/sms_campaign/detail/<id_campagna]]> // |
| | |
| | //Nodo specifico: <id_campagna> : id della campagna di cui si desidera ricevere le informazioni di dettaglio // |
| | |
| | //Parametri JSON: // |
| | |
| | //• username: il proprio username // |
| | |
| | //• password: la propria password // |
| | |
| | //esempio formattazione: {“username”:”mia_user”,”password”:”mia_password”} // |
| | |
| | //Esempio di codice CURL: // |
| | |
| | //curl -X POST [[https://api.sindacincontatto.it/sms_campaign/detail/1|https://api.sindacincontatto.it/sms_campaign/detail/1]] -H "Content-Type: application/json" -d '{"username":" mia_user ","password":" mia_password"}' // |
| | |
| | //Esempio di codice PHP: // |
| | |
| | //<?php $url = "https://api.sindacincontatto.it/sms_campaign/detail/1"; |
| | |
| | $curl = curl_init($url); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, true);; curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
| | |
| | $headers = array(); $headers["Content-Type"] = "application/json"; |
| | |
| | curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); |
| | |
| | $data = '{"username":"mia_user","password":"mia_password"}'; |
| | |
| | curl_setopt($curl, CURLOPT_POSTFIELDS, $data); |
| | |
| | //for debug only! curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $resp = curl_exec($curl); curl_close($curl); var_dump($resp); ?> Esempio javascript/ajax var url = "https://api.sindacincontatto.it/sms_campaign/detail/1"; |
| | |
| | var xhr = new XMLHttpRequest(); xhr.open("POST", url); |
| | |
| | xhr.setRequestHeader("Content-Type", "application/json"); |
| | |
| | xhr.onreadystatechange = function () { |
| | <code> |
| | |
| | if (xhr.readyState === 4) { |
| | console.log(xhr.status); |
| | console.log(xhr.responseText); |
| | }}; |
| | |
| | </code> |
| | |
| | var data = '{"username":"mia_user","password":"mia_password"}'; |
| | |
| | xhr.send(data); |
| | |
| | Risposte: |
| | |
| | Risposta corretta: |
| | |
| | { |
| | |
| | <code> |
| | "result": "OK", |
| | "data": { |
| | "dettagli_campagna": { |
| | "nome_campagna": "Campagna SMS 1", |
| | "stato_campagna": "ACTIVE", |
| | "data_attivazione": "2018-10-05 07:00:00" |
| | }, |
| | "report": { |
| | "sms_totali": 1000, |
| | "sms_inviati": 1000 |
| | } |
| | } |
| | |
| | </code> |
| | |
| | } |
| | |
| | Errore di autenticazione: |
| | |
| | { |
| | |
| | <code> |
| | "result": "KO", |
| | "mgs": "problema di autenticazione" |
| | |
| | </code> |
| | |
| | } |
| | |