<?php
// Vervang deze waarden door de juiste gegevens
$phone_ip = 'IP_ADDRESS_OF_YEALINK_PHONE';
$username = 'admin';
$password = 'password';
// Maak een inlogtoken voor de YDM API
$login_url = "http://$phone_ip/servlet?action=login_check&user=$username&password=$password";
$login_response = file_get_contents($login_url);
if (strpos($login_response, "successfully") === false) {
die("Fout bij inloggen op de telefoon.");
}
// Haal de huidige configuratie op
$config_url = "http://$phone_ip/servlet?action=get_config";
$config_response = file_get_contents($config_url);
if (!$config_response) {
die("Kan de configuratie niet ophalen.");
}
// Regex-patroon om BLF-instellingen te vinden
$pattern = '/blf(\d+)\.value=(.*)/';
// Vervang BLF-instellingen door Speed Dial
$new_config = preg_replace_callback($pattern, function($match) {
$key_number = $match[1];
$value = $match[2];
// Voeg hier de logica toe om te bepalen of je deze waarde wilt wijzigen
if (in_array($value, $values_to_change)) {
// Wijzig het key type van BLF naar Speed Dial
return "speeddial$key_number.value=$value";
} else {
return $match[0]; // Geen wijziging
}
}, $config_response);
// Stuur de bijgewerkte configuratie terug naar de telefoon
$update_url = "http://$phone_ip/servlet?action=update_config";
$update_response = file_get_contents($update_url, false, stream_context_create([
'http' => [
'method' => 'POST',
'header' => "Content-Type: application/x-www-form-urlencoded\r\n",
'content' => http_build_query(['data' => $new_config]),
],
]));
if (strpos($update_response, "successfully") === false) {
die("Fout bij het bijwerken van de configuratie.");
}
echo "Configuratie bijgewerkt.";
?>