Answers.Body: <p>If you look in CRM_Contact_BAO_Query, it looks like it takes the "location" return property into account when considering primary, but location is an array but using the api you'd have to somehow put it in the return string, so I'm not sure how you'd specify it.</p>
  
  <p>If you're willing to stray a little from the official api, there is the less official CRM_Contact_BAO_Contact::retrieve(). So something like</p>
  
  <p><code>
  $params = array('contact_id' =&gt; 4); // 4 is an example, use the desired contact id
  $defaults = array();
  $contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults);</code></p>
  
  <p>And then there's an array under $contact->phone</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-26T02:10:25.887Z
Answers.Text: Cool - even better, once I have a Contact object in `$c`, it looks like I can just retrieve the Phone objects by doing `$p = CRM_Core_BAO_Phone::allPhones($c->id)`.  Thanks for the help!
Answers.UserDisplayName: Ken Williams
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-25T17:49:54.760Z
Answers.LastActivityDate: 2016-07-25T17:49:54.760Z
Answers.UserDisplayName: Demerit
Body: <p>How can I retrieve all the phone numbers for a contact using the PHP object-oriented API?  I'm only seeing the primary phone available in the API explorer.  I want to be able to create a directory of everyone in a certain group, including all their phone numbers, with labels like "home", "work", "mobile".</p>
  
  <p>My query currently looks like this:</p>
  
  <pre><code>$api-&gt;Contact-&gt;Get(array(
               'group' =&gt; 6,
               'sequential' =&gt; 1,
               'rowCount' =&gt; 100,
               'return' =&gt; 'custom_4,display_name,email,phone,'.
                     'street_address,city,state_province,postal_code',
               'sort'=&gt;'custom_4,last_name,first_name'));
  </code></pre>
  
  <p>Thanks.</p>
  
Tags: <api><phone>
Title: Retrieve all phone info through PHP object-oriented API
ThreadText: # Retrieve all phone info through PHP object-oriented API
  
  (Asked by: username_0 on 2016-07-24)
  
  How can I retrieve all the phone numbers for a contact using the PHP object-oriented API? I'm only seeing the primary phone available in the API explorer. I want to be able to create a directory of everyone in a certain group, including all their phone numbers, with labels like "home", "work", "mobile".
  
  My query currently looks like this:
  
  ```
  $api->Contact->Get(array(
               'group' => 6,
               'sequential' => 1,
               'rowCount' => 100,
               'return' => 'custom_4,display_name,email,phone,'.
                     'street_address,city,state_province,postal_code',
               'sort'=>'custom_4,last_name,first_name'));
  
  ```
  
  Thanks.
  
  **Tags:** api, phone
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-07-25. Score: 1 | Accepted answer
  
  If you look in CRM\_Contact\_BAO\_Query, it looks like it takes the "location" return property into account when considering primary, but location is an array but using the api you'd have to somehow put it in the return string, so I'm not sure how you'd specify it.
  
  If you're willing to stray a little from the official api, there is the less official CRM\_Contact\_BAO\_Contact::retrieve(). So something like
  
  `$params = array('contact_id' => 4); // 4 is an example, use the desired contact id
  $defaults = array();
  $contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults);`
  
  And then there's an array under $contact->phone
  
  > **Comments:**
  > **username_0**: Cool - even better, once I have a Contact object in `$c`, it looks like I can just retrieve the Phone objects by doing `$p = CRM_Core_BAO_Phone::allPhones($c->id)`.  Thanks for the help!  
  
  ---
  
  