CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • V2.0 and APIs
Pages: [1]

Author Topic: V2.0 and APIs  (Read 4611 times)

dflasse

  • I post occasionally
  • **
  • Posts: 56
  • Karma: 0
    • Tout peut arriver
V2.0 and APIs
April 04, 2008, 05:57:25 am
Hi there,

I'm busy migrating our CiviCRM set up to V2. The upgrade itself ran smoothly but I'm stuck in migrating the code snippets we used with API.

I'm trying to retrieve all contact email from several groups (see below). I managed to get an array of groups but I can't get contacts belonging to a group.

Any help greatly appreciated.

 $params = array( 'title' => $param );

                //$return_properties = array('title' );
                $myGroups =& civicrm_groups_get($params);

                foreach($myGroups as $group)
                {
                $params = array('group_id' => $group['id']);
               
                $myContacts = civicrm_group_contact_get(&$params);

                        foreach ($myContacts as $contact)
                        {
                        $display .= $contact['email'] . ", ";
                        }
                }
                return $display;

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: V2.0 and APIs
April 04, 2008, 08:05:39 am
Try using civicrm_contact_search() api.

Check http://biryani.osuosl.org:8181/browse/CiviCRM/branches/v2.0/api/v2/Contact.php?r=12906

kurund
Found this reply helpful? Support CiviCRM

dflasse

  • I post occasionally
  • **
  • Posts: 56
  • Karma: 0
    • Tout peut arriver
Re: V2.0 and APIs
April 07, 2008, 12:15:58 am
Where do I find the documentation about this API? I'm a very lousy php developper and the code itself is very cryptic for me. Thanks!

dflasse

  • I post occasionally
  • **
  • Posts: 56
  • Karma: 0
    • Tout peut arriver
Re: V2.0 and APIs
April 07, 2008, 12:46:09 am
Nevermind ... I should better get some sleep!

dflasse

  • I post occasionally
  • **
  • Posts: 56
  • Karma: 0
    • Tout peut arriver
Re: V2.0 and APIs
April 07, 2008, 01:08:52 am
Well ... I'm stuck again ...

Here's the piece of code that used to work prior to V2.0:

public function search_group_contacts_tb($param){
               
                $params = array( 'title' => $param );

                $return_properties = array('title' );
                $myGroups =& crm_get_groups($params, $return_properties);
               
                foreach($myGroups as $group) {
                        $return_properties = array( 'email' );
                        $sort = array("email" => "ASC");
                       
                $myContacts =& crm_get_group_contacts(&$group, $return_propertie
s ,'Added',$sort, $offset = 0, $row_count = null );
                       
                        foreach ($myContacts as $contact) {
                    $display .= $contact->email . ", ";
                }
                }
                return $display;
        }

The crm_get_group_contact API seems not to be available anymore. So is the 'crm_get_group'. I managed to adapt the latter with the 'civicrm_groups_get' V2 API but I can't find an alternative to the first one.

The bottom line is how do I retrieve the email address from a group? civicrm_contact_search() isn't helpful since the ERD shows the groups a contact belongs to is only available through the civicrm_group_contact table. Therefore I don't see what parameter I could pass to civicrm_contact_search().

dflasse

  • I post occasionally
  • **
  • Posts: 56
  • Karma: 0
    • Tout peut arriver
Re: V2.0 and APIs
April 08, 2008, 12:36:48 am
I've seen that the API documentation has been updated. It is much clearer why my application stopped working with civiCRM 2.0. I totally missed the warnings prior to upgrade.

However, I still miss the equivalent of crm_get_group_contacts (deprecated) in the new set of APIs.

Chris Burgess

  • Ask me questions
  • ****
  • Posts: 675
  • Karma: 59
Re: V2.0 and APIs
April 08, 2008, 03:48:28 am
Did you find a way to make this work?
@xurizaemon ● www.fuzion.co.nz

dflasse

  • I post occasionally
  • **
  • Posts: 56
  • Karma: 0
    • Tout peut arriver
Re: V2.0 and APIs
April 08, 2008, 04:00:09 am
Unfortunately no.

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: V2.0 and APIs
April 09, 2008, 04:45:11 am
check http://forum.civicrm.org/index.php/topic,3008.msg13249.html#msg13249

kurund
Found this reply helpful? Support CiviCRM

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • V2.0 and APIs

This forum was archived on 2017-11-26.