Forums

API Request

 


Hi, I'm trying to get the hang of the API and my programming is a bit rusty. Hoping someone can help me out. I'm able to the API and return the results, but can't figure out how to customize my post string. I tried this and it returns all of the people, not just those in the category:

 

   

require_once('Elvanto_API.php');

$auth_details = array('api_key' => 'API_KEY', 'category_id' => 'CATEGORY_ID');
$elvanto = new Elvanto_API($auth_details);

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

$new_results=$results->people->person;

foreach ($new_results as $result) {
	echo $result->firstname . ' ' . $result->lastname . '<br>';	
	}	

     I also tried this and it returns empty:   

require_once('Elvanto_API.php');

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

$results = $elvanto->call('people/getAll/?category_id=CATEGORY_ID');

$new_results=$results->people->person;

foreach ($new_results as $result) {
	echo $result->firstname . ' ' . $result->lastname . '<br>';	
	}	

   Any help is greatly appreciated!



Hi Anthony,


Thanks for the question.


For security reasons we've had to edit your post and revoke your API key, you'll have to generate a new one to continue testing. As this is a public forum it's not a good idea to post your API Key here.


 Try the following. If you still get issues, it might be worth simply doing a var_dump of your $results.

require_once('Elvanto_API.php');
 
$auth_details = array('api_key' => 'API_KEY');
$elvanto = new Elvanto_API($auth_details);
 
$results = $elvanto->call('people/getAll/', array('category_id'=>'CATEGORY_ID'));
 
$new_results=$results->people->person;
 
foreach ($new_results as $result) {
    echo $result->firstname . ' ' . $result->lastname . '<br>'; 
    } 

Hope this helps,

Stewart  




Login or Signup to post a comment