No recent searches
Popular Articles
Sorry! nothing found for
Posted over 1 year ago by Julien Pauthier
You can extract all templates from a list of locations, and do a search&replace for each email template:
<?php $token = ""; $apikey = ""; // Fetching list of companies/locations for the account $data = file_get_contents("https://app.agendize.com/api/2.1/scheduling/companies?apiKey=$apikey&token=$token"); $results = json_decode($data); // Table header for output echo "Company name\tCompany ID\tEmail template name\tEmail template ID\n"; foreach ($results->items as $company) { // Fetching list of email templates for the current company/location $data2 = file_get_contents("https://app.agendize.com/api/2.1/scheduling/companies/$company->id/settings/messages/emails?apiKey=$apikey&token=$token"); $ct = json_decode($data2); foreach ($ct->items as $key => $value) { // Table row for output echo $company->name . "\t" . $company->id . "\t" . $value->name . "\t" . $value->id . "\n"; $ch = curl_init("https://app.agendize.com/api/2.1/scheduling/companies/$company->id/settings/messages/emails/$value->id?apiKey=$apikey&token=$token"); //replace default color with new color $updatedTemplate = str_replace('#30AF93', '#194867', $value->html); //setup request to send json via PUT $data3 = array( 'name' => $value->name, 'html' => $updatedTemplate ); $payload = json_encode($data3); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); //set the content type to application/json curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); //execute the POST request $result = curl_exec($ch); //close cURL resource curl_close($ch); } } ?>
0 Votes
0 Comments
Login or Sign up to post a comment
People who like this
This post will be deleted permanently. Are you sure?
You can extract all templates from a list of locations, and do a search&replace for each email template:
0 Votes
0 Comments
Login or Sign up to post a comment