Negli esempi PHP si utilizza la classe test_call in cui si sono impostati il $Token e l’end point che sono assegnati automaticamente nel progetto e il $RecordSeparator e il $FieldSeparator che devono essere impostati nel progetto
test_call.class :
<?php
/*
test_call esempio per help
*/
class call_class {
public $Token = "AAAxxx111........................"; // project token
public $RecordSeparator = "<record>"; // customized in project
public $FieldSeparator = "<field>"; // customized in project
public $cmd = ""; // cmd to execute
/*
* Class Constructor
*/
function __construct() {
$this->RecordSeparator = htmlspecialchars($this->RecordSeparator);
$this->FieldSeparator = htmlspecialchars($this->FieldSeparator);
}
/*
call API
*/
function call_curl() {
$encData = base64_encode($this->Token."§§§".$this->cmd); // encode string
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api1.dataindb.cloud/go.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$post = array('encData' => $encData);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($ch);
if (curl_errno($ch)) {
return "error ".curl_error($ch);
die();
}
curl_close($ch);
// received result
$result = base64_decode($result); // decode string
return trim($result);
}
}
?>