I am trying to create a lists of contact along with the membership type associated with each contact. Below is the code I have:
$result = civicrm_api3('Contact', 'get', array(
'sequential' => 1,
'return' => "tag,display_name,id,image_URL",
'contact_type' => "Organization",
'options' => array('limit' => 300),
));
I am not sure how to do join api call to both contact and membership, so that I can get all detail in one single api call.
so I am wondering if anyone can help.
So, far I have created another api call to each contact list returned form the above api call, like this:
foreach($result['values'] as $member){
$ufmatch = civicrm_api3('Membership', 'get', array(
'sequential' => 1,
'contact_id' => $member['id'],
));
$member['member_type'] = $ufmatch['values'][0]['membership_name'];
$nodes[] = array(
'node' => $member,
);
}
$members = array(
'nodes' => $nodes,
);
return drupal_json_output($members);
But there are hundreds of contact list. So, it takes almost 2-3 mins load all data.
Can anyone please guide me in a right direction. Thanks in advance.