Forums

Groups Call Formatting

I'm working on getting a list of groups. I'm starting small and working my way up. Here's the code I have, but it isn't returning anything. What am I missing?


 

<?php 
require_once('Elvanto_API.php');

$auth_details = array('api_key' => 'XX');
$elvanto = new Elvanto_API($auth_details);

$results = $elvanto->call('groups/getAll/');

$new_results = $results;
	
	foreach ($new_results as $result){
	echo $result->name;
}

 

Hi Steve.


If you view our API Documentation you'll see that the data for the groups isn't in the top level. 


You'll want to do something along the following lines. (I haven't tested this exactly, but it would be something like this!)

<?php 
require_once('Elvanto_API.php');
 
$auth_details = array('api_key' => 'XX');
$elvanto = new Elvanto_API($auth_details);
 
$results = $elvanto->call('groups/getAll/');
 
$new_results = $results->groups->group;
     
    foreach ($new_results as $result){
    echo $result->name;
}

 Stewart

Thanks. I tried it and it still didn't work. No output and no errors. I've done a var dump and that works just fine. 

Does the var dump of new_results of $new_results work, or only when you var dump $results?


Login or Signup to post a comment