Sincronizam Outlook cu Voip telefonul in cazul meu GRANDSTREAM GXP-2000 care permite importul contactelor prin XML.
Exportam contactele din outlooc intr-un fisier text, cu delimitator TAB.
Rulam scriptul:
<?php
$file = 'contacts.txt';
$xml_file = 'gs_phonebook.xml';
$f = fopen($file, 'r');
$delimiter = "\t";
$line = fgets($f);
$AddressBook = array();
$total = 0;
while (!feof($f)) {
$line = fgets($f);
$a = explode($delimiter, $line);
if (count($a) > 1)
{
$FirstName = $a[1];
$LastName = $a[3];
$Tel = array();
$tels = array(31, 32, 34, 36,37,38,40,41,42);
foreach ($tels as $id)
{
if (isset($a[$id]) && $acc = CheckNumber($a[$id]))
{
$Tel[] = array(‘tel’ => $a[$id], 'acc' => $acc);
}
}
if (count($Tel))
{
$i = 1;
foreach ($Tel as $tel)
{
$Contact = array();
$Contact[‘LastName’] = $LastName.($i > 1 ? ' – '.$i : '');
$Contact[‘FirstName’] = $FirstName;
$Contact[‘phonenumber’] = $tel[‘tel’];
$Contact[‘accountindex’] = $tel[‘acc’];
$AddressBook[] = $Contact;
$i++;
$total++;
}
}
}
//echo '<pre>'; print_r($a); exit;
}
fclose($f);
//Facem XML-ul
$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output .= "<AddressBook>\n";
foreach ($AddressBook as $Contact){
$xml_output .= "\t<Contact>\n";
$xml_output .= "\t\t<LastName>" . $Contact[‘LastName’] . "</LastName>\n";
$xml_output .= "\t\t<FirstName>" . $Contact[‘FirstName’] . "</FirstName>\n";
$xml_output .= "\t\t\t<Phone>\n\t\t\t\t<phonenumber>" . $Contact[‘phonenumber’] . "</phonenumber>\n";
$xml_output .= "\t\t\t\t<accountindex>" . $Contact[‘accountindex’] . "</accountindex>\n";
$xml_output .= "\t\t\t</Phone>\n";
$xml_output .= "\t</Contact>\n";
}
$xml_output .= "</AddressBook>";
$f = fopen($xml_file, 'w');
fwrite($f, $xml_output);
fclose($f);
echo 'Total adaugate : '.$total;
function CheckNumber($number)
{
if (strlen($number) < 5)
{
return false;
}
if (substr($number, 0, 1) == '+')
{
str_replace('+', '', $number);
if (substr($number, 0, 2) == '40')
{
//E romania
return 2;
}
//Altfel e pe moldova
return 1;
}
if (substr($number, 0, 2) == '06' || substr($number, 0, 3) == '078' || substr($number, 0, 3) == '079')
{
return 1;
}
return 2;
}
Uplodam fisierul pe un domeniu.com
In setarile telefonului bifam "Phonebook XML Download: YES, HTTP." si indicam calea catre domeniu, NU SI FISIERUL!
EX: www.lideri.com nu www.lideri.com/gs_phonebook.xml
setam o perioada la care sa se faca resincronizarea, si resetam telefonul, ar trebui sa incarce xml-ul la butare.
Succes!