0

我试图调用 Harvest API 来获取客户端信息。我尝试遵循 Harvest 提供的官方文档。但是一旦我运行代码它没有输出。

这是我的代码

<?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";

}

?>

但它总是返回不成功。请就我如何克服这个问题提出建议。

4

1 回答 1

0

我今天尝试使用相同的代码来处理它,并猜猜它的工作原理!我只是添加了几行来打印数组。

<?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";

}
于 2016-04-14T15:38:01.740 回答