Forums

GET group list php code snippet

Has anyone used the Api to pull a list of groups? I want to use it on our Wordpress site. I'm woe seeing if anyone has already written the code and would be willing to share it.

Hi Steve,


Thanks for the email.


Getting the list of groups from your Elvanto account should be as easy as follows.


 

require_once('Elvanto_API.php');

$auth_details = array('api_key' => 'your API Key');
$elvanto = new Elvanto_API($auth_details);

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

 What you do with that data though is a different question though. You may also wish to filter this call to a specific group category etc.


Stewart

 Does this look correct? I've obviously masked the API key. 

<?php 
require_once('https://api.elvanto.com/v1/groups/getAll.php');

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

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

 

Does this look correct? I tried the below code and it didn't work. I didn't get any results or any error messages. 

<?php 
require_once('https://api.elvanto.com/v1/groups/getAll.php');

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

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

 

Never mind. Got it figured out.

Hi Steve


I just replied to your other question. Sorry that the forums marked the replies as Spam! The spam filters are quiet zealous.


Let me know if you're having issues still.


Stewart


I got this working. How do I filter by status? I only want to display active groups. I've tried the below and it didn't work. 

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

  

 Try this.

$results = $elvanto->call('groups/getAll', $params=array("suspended" => "no");

 

Work's perfectly. Thanks!


Login or Signup to post a comment