Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get contact #53

Closed
fury118 opened this issue Jul 8, 2016 · 5 comments
Closed

get contact #53

fury118 opened this issue Jul 8, 2016 · 5 comments

Comments

@fury118
Copy link

fury118 commented Jul 8, 2016

I acces my contact number 2 on my exchange.
I can get these data: name, surname, jobtitle, company, ...
I can't get thes data: mails,phone number and address.

here my code:

<?php
require_once 'vendor/autoload.php';
use garethp\ews\Contacts\ContactsAPI as API;
use \garethp\ews\API\Enumeration;

$api = API::withUsernameAndPassword('*****', '****', '****');
$contacts = $api->getContacts();

echo($contacts[2]->getItemId()->getId())."<br>";
echo($contacts[2]->getGivenName())."<br>";
echo($contacts[2]->getSurname())."<br>";
echo($contacts[2]->getjobTitle())."<br>";
echo($contacts[2]->getCompanyName())."<br>";
echo($contacts[2]->getLastModifiedTime())."<br>";
print_r($contacts[2]->getPhoneNumbers());
echo"<br><br>";
print_r($contacts[2]->getEmailAddresses());
echo"<br><br>";             
print_r($contacts[2]->getPhysicalAddresses());
?>

here the result:

AQMkADE4YTg2ODEyLThjZDYtNDliMi1hM2Y2LTk3NThmN2NmZGM5MABGAAAD9G1ZxG9VTU0AvTBInvWTfMMHALWulK21A0FFsvNfOaLbENAAAAIBDgAAALWulK21A0FFsvNfOaLbENAAAAIVRAAAAA==
prenomtest
nomtest
fonctiontest
societetest
2016-07-08T07:35:26Z
stdClass Object ( [Entry] => Array ( [0] => garethp\ews\API\Type\PhoneNumberDictionaryEntryType Object ( [key:protected] => BusinessFax [_] => faxtest [_value] => [_typeMap:protected] => Array ( ) ) [1] => garethp\ews\API\Type\PhoneNumberDictionaryEntryType Object ( [key:protected] => BusinessPhone [_] => teltest [_value] => [_typeMap:protected] => Array ( ) ) [2] => garethp\ews\API\Type\PhoneNumberDictionaryEntryType Object ( [key:protected] => MobilePhone [_] => porttest [_value] => [_typeMap:protected] => Array ( ) ) ) ) 

stdClass Object ( [Entry] => garethp\ews\API\Type\EmailAddressDictionaryEntryType Object ( [key:protected] => EmailAddress1 [name:protected] => [routingType:protected] => [mailboxType:protected] => [_] => nomprenolm@mail.fr [_value] => [_typeMap:protected] => Array ( ) ) ) 

stdClass Object ( [Entry] => garethp\ews\API\Type\PhysicalAddressDictionaryEntryType Object ( [key:protected] => Business [street:protected] => ruetest [city:protected] => villetest [state:protected] => deptest [countryOrRegion:protected] => paystest [postalCode:protected] => cptest [_] => [_value] => [_typeMap:protected] => Array ( ) ) )
@Garethp
Copy link
Owner

Garethp commented Jul 9, 2016

It looks to me like you were able to get the phone numbers, addresses and email addresses just fine. What problem are you having?

@fury118
Copy link
Author

fury118 commented Jul 9, 2016

I just want to get the phone mumber as a var and not as un object
to have an "echo" like "teltest"

@Garethp
Copy link
Owner

Garethp commented Jul 10, 2016

You know how to use PHP, right? You should be able to just get the value from the object...

@fury118
Copy link
Author

fury118 commented Jul 10, 2016

I find the way. I'm still disturbed by the ->get_()

here my code:

getContacts(); echo($contacts[2]->getItemId()->getId())."
"; echo($contacts[2]->getGivenName())."
"; echo($contacts[2]->getSurname())."
"; echo($contacts[2]->getjobTitle())."
"; echo($contacts[2]->getCompanyName())."
"; echo($contacts[2]->getLastModifiedTime())."
"; echo($contacts[2]->getPhysicalAddresses()->Entry->getStreet())."
"; echo($contacts[2]->getPhysicalAddresses()->Entry->getPostalCode())."
"; echo($contacts[2]->getPhysicalAddresses()->Entry->getCity())."
"; echo($contacts[2]->getPhysicalAddresses()->Entry->getState())."
"; echo($contacts[2]->getPhysicalAddresses()->Entry->getcountryOrRegion())."
"; echo($contacts[2]->getPhoneNumbers()->Entry[0]->get_())."
"; echo($contacts[2]->getPhoneNumbers()->Entry[1]->get_() )."
"; echo($contacts[2]->getPhoneNumbers()->Entry[2]->get_() )."
"; echo($contacts[2]->getEmailAddresses()->Entry->get_())."
"; ?>

here the result:

A_DEEZ4T_*****_DlERi1EDFAAD_xG9V_TAvWT_VRAArfeAA==
prenomtest
nomtest
fonctiontest
societetest
2016-07-08T07:35:26Z
ruetest
cptest
villetest
deptest
paystest
faxtest
teltest
porttest
nomprenolm@mail.fr

@fury118 fury118 closed this as completed Jul 11, 2016
@Garethp
Copy link
Owner

Garethp commented Jul 12, 2016

You can replace the get_() by casting to string. So you can either do

$contacts[2]->getPhoneNumbers()->Entry[2]->__toString()

Or

echo ((string) $contacts[2]->getPhoneNumbers()->Entry[2]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants