使用PHP EWS更新联系人物理地址

使用PHP EWS更新联系人物理地址,php,exchangewebservices,Php,Exchangewebservices,我正忙于编写一些代码,这些代码将通过PHPEWS更新Microsoft exchange服务器上的物理地址 但就我的一生而言,我不太明白如何更新物理地址,我可以更新除此之外的所有内容 这是我的密码 // Update Physical Address. $field = new EWSType_SetItemFieldType(); $field->IndexedFieldURI->FieldURI = 'contacts:PhysicalAddress:Street'; $fiel

我正忙于编写一些代码,这些代码将通过PHPEWS更新Microsoft exchange服务器上的物理地址

但就我的一生而言,我不太明白如何更新物理地址,我可以更新除此之外的所有内容

这是我的密码

// Update Physical Address.
$field = new EWSType_SetItemFieldType();
$field->IndexedFieldURI->FieldURI = 'contacts:PhysicalAddress:Street';
$field->IndexedFieldURI->FieldIndex = EWSType_PhysicalAddressKeyType::HOME;

$field->Contact = new EWSType_ContactItemType();
$field->Contact->PhysicalAddress = new EWSType_PhysicalAddressDictionaryType();

$address = new EWSType_PhysicalAddressDictionaryEntryType();
$address->Key = EWSType_PhysicalAddressKeyType::HOME;
$address->_ = $street;

$field->Contact->PhysicalAddresses->Entry = $address;
$change->Updates->SetItemField[] = $field;
我一直得到以下错误

Array ( [0] => stdClass Object ( [MessageText] => An object within a change description must contain one and only one property to modify. [ResponseCode] => ErrorIncorrectUpdatePropertyCount [DescriptiveLinkKey] => 0 [ResponseClass] => Error [Items] => stdClass Object ( ) ) ) 

希望有人能帮忙

经过几个小时的反复试验,我终于自己解决了这个问题

这是密码

// Update Physical Address.
$field = new EWSType_SetItemFieldType(); 
$field->IndexedFieldURI->FieldURI = 'contacts:PhysicalAddress:Street';
$field->IndexedFieldURI->FieldIndex = EWSType_PhysicalAddressKeyType::HOME;

$field->Contact = new EWSType_ContactItemType();
$field->Contact->PhysicalAddresses = new EWSType_PhysicalAddressDictionaryType();
$address = new EWSType_PhysicalAddressDictionaryEntryType();
$address->Key = EWSType_PhysicalAddressKeyType::HOME;

$field->Contact->PhysicalAddresses->Entry = $address;
$field->Contact->PhysicalAddresses->Entry->Street = $street;

$change->Updates->SetItemField[] = $field; 
基本上,您可以设置字段URI和字段索引(必须记住,更新时一次只能更新一个项目),您将看到字段URI设置为“contacts:physicaldaddress:Street”,这是因为您一次只能更新一个项目

接下来,我们创建联系人标签,然后是PhysicalAddresses标签,然后是Entry标签,并为其提供Home键,最后设置Street标签

它创建的实际XML将如下所示

<t:SetItemField>
<t:IndexedFieldURI FieldURI="contacts:PhysicalAddress:CountryOrRegion" FieldIndex="Business" />
<t:Contact>
<t:PhysicalAddresses>
<t:Entry Key="Business">
<t:CountryOrRegion>
</t:CountryOrRegion>
</t:Entry>
</t:PhysicalAddresses>
</t:Contact>
</t:SetItemField>

就这样,它会更新街道地址。你现在需要做的就是把代码放在一个循环中,使用一个开关来查看地址的哪一部分你要更新,然后点击你的叔叔


哦,希望这对别人有帮助。

谢谢菲利普。在过去的3-4个小时里,我也有同样的问题。你救了我。它们应该显示某个地方,您需要逐个放置密钥来更新它。