0

I was trying to call the Harvest API to get the client Information. I tried to follow the official documentation provided by Harvest. But Once I run the code It gives no output.

Here is my code

<?php
require_once(dirname(__FILE__) . '/HarvestAPI.php');
spl_autoload_register(array('HarvestAPI', 'autoload') );

$harvest_user = $user; // Your Harvest username, usually an email address
$harvest_pass = $password; // Your Harvest password
$harvest_account = $account;


$harvestAPI = new HarvestAPI();
$harvestAPI->setUser($harvest_user);
$harvestAPI->setPassword($harvest_pass);
$harvestAPI->setAccount($harvest_account);

$harvestAPI->setRetryMode( HarvestAPI::RETRY );
$harvestAPI->setSSL(true);


$result = $harvestAPI->getClients();

if( $result->isSuccess() ) {
 echo "Successful";
}
else{
echo "Not Successful";

}

?>

But it always returns not successful . Kindly give suggestions on how I could overcome this problem.

user3402248
  • 439
  • 6
  • 25

1 Answers1

0

I tried working on it today with the same code and guess what it worked! I just added few more lines to print the array.

<?php
require_once(dirname(__FILE__) . '/HarvestAPI.php');
spl_autoload_register(array('HarvestAPI', 'autoload') );


$harvest_user = $user; // Your Harvest username, usually an email address
$harvest_pass =$password; // Your Harvest password
$harvest_account =$account;


$harvestAPI = new HarvestAPI();
$harvestAPI->setUser($harvest_user);
$harvestAPI->setPassword($harvest_pass);
$harvestAPI->setAccount($harvest_account);

$harvestAPI->setRetryMode( HarvestAPI::RETRY );
$harvestAPI->setSSL(true);


$result = $harvestAPI->getClients();

if( $result->isSuccess() ) {
 echo "Successful";
 $data = $result->get( "data" );
print_r($data);
}
else{
echo "Not Successful";

}
user3402248
  • 439
  • 6
  • 25