加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

发布时间:2020-12-13 17:22:00 所属栏目:PHP教程 来源:网络整理
导读:我正忙着编写一些代码,通过 PHPEWS更新Microsoft Exchange服务器上的物理地址; 但对于我的生活,我无法弄清楚如何更新物理地址,我可以更新除此之外的所有其他内容. 这是我的代码. // Update Physical Address.$field = new EWSType_SetItemFieldType();$field
我正忙着编写一些代码,通过 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;

基本上你设置你的FieldURI和Field Index(必须记住,在更新时你一次只能更新一个项目)你会看到FieldURI被设置为“contacts:PhysicalAddress:Street”这是因为你只能更新一个项目一时间

接下来我们创建Contact标签,然后创建PhysicalAddresses标签,然后创建Entry标签,并为其提供Home of Key,最后我们设置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>

这就是它,它然后更新街道地址.现在你需要做的就是把代码放在一个循环中,使用开关来查看你想要更新的地址的哪一部分并且让你的叔叔陷入困境.

哦,希望这有助于某人.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读