Ejemplo n.º 1
0
 public static function Test($scheme, $server, $port, $userName, $userPassword, $mailbox, $arPFolders = array(), $bDebug = false)
 {
     $arAvailableFolders = array("calendar", "contacts", "tasks");
     if (!is_array($arPFolders)) {
         $arPFolders = array($arPFolders);
     }
     $arFolders = array();
     foreach ($arPFolders as $value) {
         if (in_array($value, $arAvailableFolders)) {
             $arFolders[] = $value;
         }
     }
     if (count($arFolders) <= 0) {
         $arFolders = $arAvailableFolders;
     }
     $arMessages = array();
     if (in_array("calendar", $arFolders)) {
         $e = new CDavExchangeCalendar($scheme, $server, $port, $userName, $userPassword);
         if ($bDebug) {
             $e->Debug();
         }
         $calendarId = null;
         $r = $e->AddCalendar(array("NAME" => "TestCalendarFolderName4", "MAILBOX" => $mailbox));
         $arMessages = array_merge($arMessages, $e->GetErrors());
         foreach ($r as $v) {
             $calendarId = $v;
         }
         if (is_null($calendarId)) {
             $arMessages[] = array("ERROR", "Calendar folder creation error.");
         } else {
             $arMessages[] = array("SUCCESS", "Calendar folder was successfully created (Id = " . $calendarId["XML_ID"] . ", ChangeKey = " . $calendarId["MODIFICATION_LABEL"] . ").");
             $r = $e->UpdateCalendar($calendarId, array("NAME" => "New TestCalendarFolderName4"));
             $arMessages = array_merge($arMessages, $e->GetErrors());
             $calendarId = null;
             foreach ($r as $v) {
                 $calendarId = $v;
             }
             if (is_null($calendarId)) {
                 $arMessages[] = array("ERROR", "Calendar folder modification error.");
             } else {
                 $arMessages[] = array("SUCCESS", "Calendar folder was successfully updated (Id = " . $calendarId["XML_ID"] . ", ChangeKey = " . $calendarId["MODIFICATION_LABEL"] . ").");
                 $bFound = false;
                 $r = $e->GetCalendarsList(array("MAILBOX" => $mailbox));
                 $arMessages = array_merge($arMessages, $e->GetErrors());
                 foreach ($r as $v) {
                     if ($v["NAME"] == "New TestCalendarFolderName4" && $v["XML_ID"] == $calendarId["XML_ID"]) {
                         $bFound = true;
                     }
                 }
                 if (!$bFound) {
                     $arMessages[] = array("ERROR", "Calendar folder is not found by list.");
                 } else {
                     $arMessages[] = array("SUCCESS", "Calendar folder was successfully found by list.");
                     $bFound = false;
                     $r = $e->GetCalendarById($calendarId["XML_ID"]);
                     $arMessages = array_merge($arMessages, $e->GetErrors());
                     foreach ($r as $v) {
                         if ($v["NAME"] == "New TestCalendarFolderName4" && $v["XML_ID"] == $calendarId["XML_ID"]) {
                             $bFound = true;
                         }
                     }
                     if (!$bFound) {
                         $arMessages[] = array("ERROR", "Calendar folder is not found by id.");
                     } else {
                         $arMessages[] = array("SUCCESS", "Calendar folder was successfully found by id.");
                         $itemId = null;
                         $arFields = array("MAILBOX" => $mailbox, "CALENDAR_ID" => $calendarId["XML_ID"], "NAME" => "TestCalendarItem Name", "DETAIL_TEXT" => "TestCalendarItem detail text", "DETAIL_TEXT_TYPE" => "html", "PROPERTY_IMPORTANCE" => "normal", "PROPERTY_REMIND_SETTINGS" => "20_min", "ACTIVE_FROM" => "16.10.2011 09:00:00", "ACTIVE_TO" => "16.10.2011 09:30:00", "PROPERTY_LOCATION" => "Some location");
                         $r = $e->Add($arFields);
                         $arMessages = array_merge($arMessages, $e->GetErrors());
                         foreach ($r as $v) {
                             $itemId = $v;
                         }
                         if (is_null($itemId)) {
                             $arMessages[] = array("ERROR", "Calendar item creation error.");
                         } else {
                             $arMessages[] = array("SUCCESS", "Calendar item was successfully created (Id = " . $itemId["XML_ID"] . ", ChangeKey = " . $itemId["MODIFICATION_LABEL"] . ").");
                             $arFields = array("NAME" => "New TestCalendarItem Name", "DETAIL_TEXT" => "TestCalendarItem detail text", "DETAIL_TEXT_TYPE" => "text", "ACTIVE_FROM" => "17.10.2011 09:00:00", "ACTIVE_TO" => "17.10.2011 09:30:00", "PROPERTY_LOCATION" => "Some new location");
                             $r = $e->Update($itemId, $arFields);
                             $itemId = null;
                             $arMessages = array_merge($arMessages, $e->GetErrors());
                             foreach ($r as $v) {
                                 $itemId = $v;
                             }
                             if (is_null($itemId)) {
                                 $arMessages[] = array("ERROR", "Calendar item modification error.");
                             } else {
                                 $arMessages[] = array("SUCCESS", "Calendar item was successfully updated (Id = " . $itemId["XML_ID"] . ", ChangeKey = " . $itemId["MODIFICATION_LABEL"] . ").");
                                 $bFound = false;
                                 $r = $e->GetList(array("Mailbox" => $mailbox, "CalendarId" => $calendarId["XML_ID"]), array("ItemShape" => "AllProperties"));
                                 $arMessages = array_merge($arMessages, $e->GetErrors());
                                 foreach ($r as $v) {
                                     if ($v["NAME"] == "New TestCalendarItem Name" && $v["XML_ID"] == $itemId["XML_ID"]) {
                                         $bFound = true;
                                     }
                                 }
                                 if (!$bFound) {
                                     $arMessages[] = array("ERROR", "Calendar item is not found by list.");
                                 } else {
                                     $arMessages[] = array("SUCCESS", "Calendar item was successfully found by list.");
                                     $bFound = false;
                                     $r = $e->GetById($itemId["XML_ID"]);
                                     $arMessages = array_merge($arMessages, $e->GetErrors());
                                     foreach ($r as $v) {
                                         if ($v["NAME"] == "New TestCalendarItem Name" && $v["XML_ID"] == $itemId["XML_ID"]) {
                                             $bFound = true;
                                         }
                                     }
                                     if (!$bFound) {
                                         $arMessages[] = array("ERROR", "Calendar item is not found by id.");
                                     } else {
                                         $arMessages[] = array("SUCCESS", "Calendar item was successfully found by id.");
                                         $r = $e->Delete($itemId["XML_ID"]);
                                         if (!$r) {
                                             $arMessages[] = array("ERROR", "Calendar item deletion error.");
                                         } else {
                                             $arMessages[] = array("SUCCESS", "Calendar item was successfully deleted.");
                                             $bFound = false;
                                             $r = $e->GetList(array("Mailbox" => $mailbox, "CalendarId" => $calendarId["XML_ID"]), array("ItemShape" => "IdOnly"));
                                             $arMessages = array_merge($arMessages, $e->GetErrors());
                                             foreach ($r as $v) {
                                                 $bFound = true;
                                             }
                                             if ($bFound) {
                                                 $arMessages[] = array("ERROR", "Calendar folder should be empty.");
                                             } else {
                                                 $arMessages[] = array("SUCCESS", "Calendar folder is empty.");
                                                 $r = $e->DeleteCalendar($calendarId["XML_ID"]);
                                                 $arMessages = array_merge($arMessages, $e->GetErrors());
                                                 if ($r) {
                                                     $arMessages[] = array("SUCCESS", "Calendar folder was successfully deleted.");
                                                 } else {
                                                     $arMessages[] = array("ERROR", "Calendar folder deletion error.");
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (in_array("contacts", $arFolders)) {
         $e = new CDavExchangeContacts($scheme, $server, $port, $userName, $userPassword);
         if ($bDebug) {
             $e->Debug();
         }
         $addressbookId = null;
         $r = $e->AddAddressbook(array("NAME" => "TestAddressbookFolderName4", "MAILBOX" => $mailbox));
         $arMessages = array_merge($arMessages, $e->GetErrors());
         foreach ($r as $v) {
             $addressbookId = $v;
         }
         if (is_null($addressbookId)) {
             $arMessages[] = array("ERROR", "Contacts folder creation error.");
         } else {
             $arMessages[] = array("SUCCESS", "Contacts folder was successfully created (Id = " . $addressbookId["XML_ID"] . ", ChangeKey = " . $addressbookId["MODIFICATION_LABEL"] . ").");
             $r = $e->UpdateAddressbook($addressbookId, array("NAME" => "New TestAddressbookFolderName4"));
             $arMessages = array_merge($arMessages, $e->GetErrors());
             $addressbookId = null;
             foreach ($r as $v) {
                 $addressbookId = $v;
             }
             if (is_null($addressbookId)) {
                 $arMessages[] = array("ERROR", "Contacts folder modification error.");
             } else {
                 $arMessages[] = array("SUCCESS", "Contacts folder was successfully updated (Id = " . $addressbookId["XML_ID"] . ", ChangeKey = " . $addressbookId["MODIFICATION_LABEL"] . ").");
                 $bFound = false;
                 $r = $e->GetAddressbooksList(array("MAILBOX" => $mailbox));
                 $arMessages = array_merge($arMessages, $e->GetErrors());
                 foreach ($r as $v) {
                     if ($v["NAME"] == "New TestAddressbookFolderName4" && $v["XML_ID"] == $addressbookId["XML_ID"]) {
                         $bFound = true;
                     }
                 }
                 if (!$bFound) {
                     $arMessages[] = array("ERROR", "Contacts folder is not found by list.");
                 } else {
                     $arMessages[] = array("SUCCESS", "Contacts folder was successfully found by list.");
                     $bFound = false;
                     $r = $e->GetAddressbookById($addressbookId["XML_ID"]);
                     $arMessages = array_merge($arMessages, $e->GetErrors());
                     foreach ($r as $v) {
                         if ($v["NAME"] == "New TestAddressbookFolderName4" && $v["XML_ID"] == $addressbookId["XML_ID"]) {
                             $bFound = true;
                         }
                     }
                     if (!$bFound) {
                         $arMessages[] = array("ERROR", "Contacts folder is not found by id.");
                     } else {
                         $arMessages[] = array("SUCCESS", "Contacts folder was successfully found by id.");
                         $itemId = null;
                         $arFields = array("MAILBOX" => $mailbox, "ADDRESSBOOK_ID" => $addressbookId["XML_ID"], "NAME" => "TestAddressbookItem Name", "LAST_NAME" => "MyLastName", "SECOND_NAME" => "MySecondName", "EMAIL" => "*****@*****.**", "WORK_POSITION" => "Programmer", "WORK_ZIP" => "236001", "WORK_CITY" => "Kaliningrad", "WORK_STREET" => "Kirov str., 261", "PERSONAL_PHONE" => "6547646546", "PERSONAL_MOBILE" => "55435656", "WORK_PHONE" => "876467343", "WORK_FAX" => "345737365", "WORK_COMPANY" => "Bitrix", "WORK_WWW" => "http://www.1c-bitrix.com", "PERSONAL_ICQ" => "535435353", "WORK_COUNTRY" => 23);
                         $r = $e->Add($arFields);
                         $arMessages = array_merge($arMessages, $e->GetErrors());
                         foreach ($r as $v) {
                             $itemId = $v;
                         }
                         if (is_null($itemId)) {
                             $arMessages[] = array("ERROR", "Contacts item creation error.");
                         } else {
                             $arMessages[] = array("SUCCESS", "Contacts item was successfully created (Id = " . $itemId["XML_ID"] . ", ChangeKey = " . $itemId["MODIFICATION_LABEL"] . ").");
                             $arFields = array("NAME" => "New TestAddressbookItem Name", "LAST_NAME" => "My new LastName", "SECOND_NAME" => "MySecondName", "EMAIL" => "*****@*****.**", "WORK_POSITION" => "Programmer", "WORK_ZIP" => "236001", "WORK_CITY" => "Kaliningrad", "WORK_STREET" => "Kirov str., 261", "PERSONAL_PHONE" => "6547646546", "PERSONAL_MOBILE" => "55435656", "WORK_PHONE" => "876467343", "WORK_FAX" => "345737365", "WORK_COMPANY" => "Bitrix", "WORK_WWW" => "http://www.1c-bitrix.com", "PERSONAL_ICQ" => "535435353", "WORK_COUNTRY" => 23);
                             $r = $e->Update($itemId, $arFields);
                             $itemId = null;
                             $arMessages = array_merge($arMessages, $e->GetErrors());
                             foreach ($r as $v) {
                                 $itemId = $v;
                             }
                             if (is_null($itemId)) {
                                 $arMessages[] = array("ERROR", "Contacts item modification error.");
                             } else {
                                 $arMessages[] = array("SUCCESS", "Contacts item was successfully updated (Id = " . $itemId["XML_ID"] . ", ChangeKey = " . $itemId["MODIFICATION_LABEL"] . ").");
                                 $bFound = false;
                                 $r = $e->GetList(array("Mailbox" => $mailbox, "AddressbookId" => $addressbookId["XML_ID"]), array("ItemShape" => "AllProperties"));
                                 $arMessages = array_merge($arMessages, $e->GetErrors());
                                 foreach ($r as $v) {
                                     if ($v["NAME"] == "New TestAddressbookItem Name" && $v["XML_ID"] == $itemId["XML_ID"]) {
                                         $bFound = true;
                                     }
                                 }
                                 if (!$bFound) {
                                     $arMessages[] = array("ERROR", "Contacts item is not found by list.");
                                 } else {
                                     $arMessages[] = array("SUCCESS", "Contacts item was successfully found by list.");
                                     $bFound = false;
                                     $r = $e->GetById($itemId["XML_ID"]);
                                     $arMessages = array_merge($arMessages, $e->GetErrors());
                                     foreach ($r as $v) {
                                         if ($v["NAME"] == "New TestAddressbookItem Name" && $v["XML_ID"] == $itemId["XML_ID"]) {
                                             $bFound = true;
                                         }
                                     }
                                     if (!$bFound) {
                                         $arMessages[] = array("ERROR", "Contacts item is not found by id.");
                                     } else {
                                         $arMessages[] = array("SUCCESS", "Contacts item was successfully found by id.");
                                         $r = $e->Delete($itemId["XML_ID"]);
                                         if (!$r) {
                                             $arMessages[] = array("ERROR", "Contacts item deletion error.");
                                         } else {
                                             $arMessages[] = array("SUCCESS", "Contacts item was successfully deleted.");
                                             $bFound = false;
                                             $r = $e->GetList(array("Mailbox" => $mailbox, "AddressbookId" => $addressbookId["XML_ID"]), array("ItemShape" => "IdOnly"));
                                             $arMessages = array_merge($arMessages, $e->GetErrors());
                                             foreach ($r as $v) {
                                                 $bFound = true;
                                             }
                                             if ($bFound) {
                                                 $arMessages[] = array("ERROR", "Contacts folder should be empty.");
                                             } else {
                                                 $arMessages[] = array("SUCCESS", "Contacts folder is empty.");
                                                 $r = $e->DeleteAddressbook($addressbookId["XML_ID"]);
                                                 $arMessages = array_merge($arMessages, $e->GetErrors());
                                                 if ($r) {
                                                     $arMessages[] = array("SUCCESS", "Contacts folder was successfully deleted.");
                                                 } else {
                                                     $arMessages[] = array("ERROR", "Contacts folder deletion error.");
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (in_array("tasks", $arFolders)) {
         $e = new CDavExchangeTasks($scheme, $server, $port, $userName, $userPassword);
         if ($bDebug) {
             $e->Debug();
         }
         $folderId = null;
         $r = $e->AddFolder(array("NAME" => "TestFolderFolderName6", "MAILBOX" => $mailbox));
         $arMessages = array_merge($arMessages, $e->GetErrors());
         foreach ($r as $v) {
             $folderId = $v;
         }
         if (is_null($folderId)) {
             $arMessages[] = array("ERROR", "Tasks folder creation error.");
         } else {
             $arMessages[] = array("SUCCESS", "Tasks folder was successfully created (Id = " . $folderId["XML_ID"] . ", ChangeKey = " . $folderId["MODIFICATION_LABEL"] . ").");
             $r = $e->UpdateFolder($folderId, array("NAME" => "New TestFolderFolderName6"));
             $arMessages = array_merge($arMessages, $e->GetErrors());
             $folderId = null;
             foreach ($r as $v) {
                 $folderId = $v;
             }
             if (is_null($folderId)) {
                 $arMessages[] = array("ERROR", "Tasks folder modification error.");
             } else {
                 $arMessages[] = array("SUCCESS", "Tasks folder was successfully updated (Id = " . $folderId["XML_ID"] . ", ChangeKey = " . $folderId["MODIFICATION_LABEL"] . ").");
                 $bFound = false;
                 $r = $e->GetFoldersList(array("MAILBOX" => $mailbox));
                 $arMessages = array_merge($arMessages, $e->GetErrors());
                 foreach ($r as $v) {
                     if ($v["NAME"] == "New TestFolderFolderName6" && $v["XML_ID"] == $folderId["XML_ID"]) {
                         $bFound = true;
                     }
                 }
                 if (!$bFound) {
                     $arMessages[] = array("ERROR", "Tasks folder is not found by list.");
                 } else {
                     $arMessages[] = array("SUCCESS", "Tasks folder was successfully found by list.");
                     $bFound = false;
                     $r = $e->GetFolderById($folderId["XML_ID"]);
                     $arMessages = array_merge($arMessages, $e->GetErrors());
                     foreach ($r as $v) {
                         if ($v["NAME"] == "New TestFolderFolderName6" && $v["XML_ID"] == $folderId["XML_ID"]) {
                             $bFound = true;
                         }
                     }
                     if (!$bFound) {
                         $arMessages[] = array("ERROR", "Tasks folder is not found by id.");
                     } else {
                         $arMessages[] = array("SUCCESS", "Tasks folder was successfully found by id.");
                         $itemId = null;
                         $arFields = array("MAILBOX" => $mailbox, "FOLDER_ID" => $folderId["XML_ID"], "SUBJECT" => "TestFolderItem Name", "BODY" => "Should be done!", "BODY_TYPE" => "text", "IMPORTANCE" => "High", "START_DATE" => "20.10.2011", "DUE_DATE" => "25.10.2011", "PERCENT_COMPLETE" => "0", "STATUS" => "NotStarted", "TOTAL_WORK" => "123", "REMINDER_MINUTES_BEFORE_START" => 365);
                         $r = $e->Add($arFields);
                         $arMessages = array_merge($arMessages, $e->GetErrors());
                         foreach ($r as $v) {
                             $itemId = $v;
                         }
                         if (is_null($itemId)) {
                             $arMessages[] = array("ERROR", "Tasks item creation error.");
                         } else {
                             $arMessages[] = array("SUCCESS", "Tasks item was successfully created (Id = " . $itemId["XML_ID"] . ", ChangeKey = " . $itemId["MODIFICATION_LABEL"] . ").");
                             $arFields = array("SUBJECT" => "New TestFolderItem Name", "BODY" => "Should be done!!!", "BODY_TYPE" => "text", "IMPORTANCE" => "Low", "START_DATE" => "20.10.2011", "DUE_DATE" => "24.10.2011", "PERCENT_COMPLETE" => "0", "STATUS" => "NotStarted", "TOTAL_WORK" => "23", "REMINDER_MINUTES_BEFORE_START" => 365);
                             $r = $e->Update($itemId, $arFields);
                             $itemId = null;
                             $arMessages = array_merge($arMessages, $e->GetErrors());
                             foreach ($r as $v) {
                                 $itemId = $v;
                             }
                             if (is_null($itemId)) {
                                 $arMessages[] = array("ERROR", "Tasks item modification error.");
                             } else {
                                 $arMessages[] = array("SUCCESS", "Tasks item was successfully updated (Id = " . $itemId["XML_ID"] . ", ChangeKey = " . $itemId["MODIFICATION_LABEL"] . ").");
                                 $bFound = false;
                                 $r = $e->GetList(array("Mailbox" => $mailbox, "FolderId" => $folderId["XML_ID"]), array("ItemShape" => "AllProperties"));
                                 $arMessages = array_merge($arMessages, $e->GetErrors());
                                 foreach ($r as $v) {
                                     if ($v["SUBJECT"] == "New TestFolderItem Name" && $v["XML_ID"] == $itemId["XML_ID"]) {
                                         $bFound = true;
                                     }
                                 }
                                 if (!$bFound) {
                                     $arMessages[] = array("ERROR", "Tasks item is not found by list.");
                                 } else {
                                     $arMessages[] = array("SUCCESS", "Tasks item was successfully found by list.");
                                     $bFound = false;
                                     $r = $e->GetById($itemId["XML_ID"]);
                                     $arMessages = array_merge($arMessages, $e->GetErrors());
                                     foreach ($r as $v) {
                                         if ($v["SUBJECT"] == "New TestFolderItem Name" && $v["XML_ID"] == $itemId["XML_ID"]) {
                                             $bFound = true;
                                         }
                                     }
                                     if (!$bFound) {
                                         $arMessages[] = array("ERROR", "Tasks item is not found by id.");
                                     } else {
                                         $arMessages[] = array("SUCCESS", "Tasks item was successfully found by id.");
                                         $r = $e->Delete($itemId["XML_ID"]);
                                         if (!$r) {
                                             $arMessages[] = array("ERROR", "Tasks item deletion error.");
                                         } else {
                                             $arMessages[] = array("SUCCESS", "Tasks item was successfully deleted.");
                                             $bFound = false;
                                             $r = $e->GetList(array("Mailbox" => $mailbox, "FolderId" => $folderId["XML_ID"]), array("ItemShape" => "IdOnly"));
                                             $arMessages = array_merge($arMessages, $e->GetErrors());
                                             foreach ($r as $v) {
                                                 $bFound = true;
                                             }
                                             if ($bFound) {
                                                 $arMessages[] = array("ERROR", "Tasks folder should be empty.");
                                             } else {
                                                 $arMessages[] = array("SUCCESS", "Tasks folder is empty.");
                                                 $r = $e->DeleteFolder($folderId["XML_ID"]);
                                                 $arMessages = array_merge($arMessages, $e->GetErrors());
                                                 if ($r) {
                                                     $arMessages[] = array("SUCCESS", "Tasks folder was successfully deleted.");
                                                 } else {
                                                     $arMessages[] = array("ERROR", "Tasks folder deletion error.");
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $arMessages;
 }
Ejemplo n.º 2
0
 public static function DoDeleteCalendar($userId, $itemXmlId)
 {
     if (DAV_EXCH_DEBUG) {
         CDav::WriteToLog("EXCHANGE DoDeleteCalendar called for user " . $userId, "MDFE");
     }
     $exchangeScheme = COption::GetOptionString("dav", "exchange_scheme", "http");
     $exchangeServer = COption::GetOptionString("dav", "exchange_server", "");
     $exchangePort = COption::GetOptionString("dav", "exchange_port", "80");
     $exchangeUsername = COption::GetOptionString("dav", "exchange_username", "");
     $exchangePassword = COption::GetOptionString("dav", "exchange_password", "");
     if (empty($exchangeServer)) {
         return "";
     }
     $exchange = new CDavExchangeCalendar($exchangeScheme, $exchangeServer, $exchangePort, $exchangeUsername, $exchangePassword);
     if (GW_DEBUG) {
         $exchange->Debug();
     }
     $exchangeMailbox = COption::GetOptionString("dav", "exchange_mailbox", "");
     $exchangeUseLogin = COption::GetOptionString("dav", "exchange_use_login", "Y");
     self::InitUserEntity();
     if ($itemXmlId == "calendar_" . $userId) {
         return '';
     }
     $userId = intval($userId);
     $dbUserList = CUser::GetList($by = "", $order = "", array("ACTIVE" => "Y", "!UF_DEPARTMENT" => false, "ID_EQUAL_EXACT" => $userId), array("SELECT" => array("ID", "LOGIN", "UF_BXDAVEX_MAILBOX", "UF_BXDAVEX_CALSYNC")));
     if ($arUser = $dbUserList->Fetch()) {
         $mailbox = $exchangeUseLogin == "Y" ? $arUser["LOGIN"] . $exchangeMailbox : $arUser["UF_BXDAVEX_MAILBOX"];
         if (!empty($mailbox)) {
             $arResult = $exchange->DeleteCalendar($itemXmlId);
             if ($arResult) {
                 return $arResult;
             }
         }
     }
     return $exchange->GetErrors();
 }