我正在尝试为使用Php-Ews创建的联系人添加多个电话号码。没有关于向联系人添加多个号码的文档。有人可以帮我找到如何做到这一点吗?
这就是我所拥有的:
// create a phone number
$phone = new Type\PhoneNumberDictionaryEntryType();
$phone->Key = new Type\PhoneNumberKeyType();
$phone->Key->_ = Type\PhoneNumberKeyType::HOME_PHONE;
$phone->_ = $info['phone'];
// create a phone number
$phone2 = new Type\PhoneNumberDictionaryEntryType();
$phone2->Key = new Type\PhoneNumberKeyType();
$phone2->Key->_ = Type\PhoneNumberKeyType::COMPANY_MAIN_PHONE;
$phone2->_ = $info['phone'];
// set the phone number
$contact->PhoneNumbers = new Type\PhoneNumberDictionaryType();
$contact->PhoneNumbers->Entry[] = $phone;
$contact->PhoneNumbers->Entry[] = $phone2;
在我看来,Entry[]
是一个数组。因此,我认为如上所述,我可以添加尽可能多的内容。但是,当我这样做时,我收到The request failed schema validation: The required attribute 'Key' is missing.
错误。我想我必须在[]
添加一个键,但我无法找出它是什么。
答案 0 :(得分:0)
我从未使用过php-ews,但我希望我找到你的答案:http://msdn.microsoft.com/en-us/library/ee159497(v=exchg.80).aspx
这些是'键'你可以用于phonenumbers。在此页面上找到它:http://msdn.microsoft.com/en-us/library/ee202532(v=exchg.80).aspx
答案 1 :(得分:0)
我发现了我需要的东西。所有Entry[]
所需要的是从0开始的索引。所以我添加了下面的内容并且它有效!谢谢你的帮助!
$phone = new Type\PhoneNumberDictionaryEntryType();
$phone->Key = new Type\PhoneNumberKeyType();
$phone->Key->_ = Type\PhoneNumberKeyType::HOME_PHONE;
$phone->_ = $info['phone'];
// create a phone number
$phone2 = new Type\PhoneNumberDictionaryEntryType();
$phone2->Key = new Type\PhoneNumberKeyType();
$phone2->Key->_ = Type\PhoneNumberKeyType::COMPANY_MAIN_PHONE;
$phone2->_ = $info['phone'];
// set the phone number
$contact->PhoneNumbers = new Type\PhoneNumberDictionaryType();
$contact->PhoneNumbers->Entry[0] = $phone;
$contact->PhoneNumbers->Entry[1] = $phone2;