[英]Harvest API-Getting Client Information
I was trying to call the Harvest API to get the client Information. 我试图调用Harvest API以获取客户端信息。 I tried to follow the official documentation provided by Harvest.
我试图遵循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.
请就如何克服这个问题提出建议。
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";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.