0

I am trying to add multiple phone numbers to a contact that I am creating with Php-Ews. There is no documentation on adding multiple numbers to a contact. Can someone help me find out how to accomplish this?

here is what I have:

    // 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;

It looked to me like the Entry[] is an array. Therefore I thought I would be able to add as many as I would like as seen above. However when I do this I get the The request failed schema validation: The required attribute 'Key' is missing. error. I figured I had to add a key to the [] but I was unable to find out what that is.

Zach Starnes
  • 3,108
  • 9
  • 39
  • 63
  • Just a wild guess: did you try naming the entries? ->Entry['Mobile'] = $phone; – DoXicK May 26 '14 at 14:29
  • Yes i did. I added ['HOME'] and any variation. I even tried adding the keys that were a part of each phone number and that still gave the same error – Zach Starnes May 26 '14 at 14:31

2 Answers2

0

i never worked with php-ews but i hope i found your answer: http://msdn.microsoft.com/en-us/library/ee159497(v=exchg.80).aspx

those are the 'keys' you can use for the phonenumbers. found it on this page: http://msdn.microsoft.com/en-us/library/ee202532(v=exchg.80).aspx

DoXicK
  • 4,784
  • 24
  • 22
0

I found out what I needed. All that the Entry[] needed was an index starting at 0. So I added the below and it worked! Thanks for all the help!

    $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;
Zach Starnes
  • 3,108
  • 9
  • 39
  • 63