<?php
// IP-adressen van de telefoons om doorheen te lussen
$ip_addresses = array("192.168.1.100", "192.168.1.101", "192.168.1.102");
// API-endpoint voor het ophalen van de configuratie van een Yealink-telefoon
$config_endpoint = "servlet?p=settings&v=ALL";
// API-endpoint voor het wijzigen van BLF-instellingen
$blf_endpoint = "servlet?p=upload";
// Gegevens voor inloggen op de telefoon (indien vereist)
$username = "admin";
$password = "YDM21000";
foreach ($ip_addresses as $ip) {
// Ophalen van de huidige configuratie van de telefoon
$config_url = "http://".$ip ."/". $config_endpoint;
$config_data = curl_get($config_url, $username, $password);
// Verwerk de configuratiegegevens en pas BLF-instellingen aan naar Fast Dial
// Stuur de gewijzigde configuratie terug naar de telefoon
$update_url = "http://".$ip ."/". $blf_endpoint;
$response = curl_post($update_url, $config_data, $username, $password);
echo "Telefoon op IP $ip is bijgewerkt.<br>";
}
// Functie om gegevens op te halen via cURL
function curl_get($url, $username, $password) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Als er inloggegevens zijn, voeg deze toe voor authenticatie
if ($username && $password) {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
}
$response = curl_exec($ch);
if (curl_errno($ch)) {
// Error handling, bijvoorbeeld: echo 'cURL error: ' . curl_error($ch);
echo 'cURL error: ' . curl_error($ch);
}
curl_close($ch);
return $response;
}
// Functie om gegevens te verzenden via cURL
function curl_post($url, $data, $username, $password) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// Als er inloggegevens zijn, voeg deze toe voor authenticatie
if ($username && $password) {
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
}
$response = curl_exec($ch);
if (curl_errno($ch)) {
// Error handling, bijvoorbeeld: echo 'cURL error: ' . curl_error($ch);
echo 'cURL error: ' . curl_error($ch);
}
curl_close($ch);
return $response;
}
?>