Add a new template.
URL: https://www.trade-copier.com/webservice/v4/template/addTemplate.php
Response: JSON object with the new template's ID.
| Field Name | Field Type | Field Description |
|---|---|---|
| name | string | Name of the template |
PHP example
<?php
$url="https://www.trade-copier.com/webservice/v4/template/addTemplate.php";
$headers = array(
'Content-Type: application/x-www-form-urlencoded',
'Authorization: Bearer [[TOKEN]]',
);
// Open connection
$ch = curl_init();
// Setting the options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$filter = ['name' => 'My first template'];
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($filter));
// Execute request
$json = json_decode(curl_exec($ch));
// Close connection
curl_close($ch);
//We check if the update was successful
if(array_key_exists('template', $json))
{
echo 'Added new Template, ID : ' . $json->template;
}
else
{
//This is an error message that can be access like this:
//echo $json->code." ".$json->error;
echo json_encode($json);
}
?>