如何通过PHP从Freshbooks API获取数据

时间:2011-08-04 04:19:58

标签: php api freshbooks-api

嗨,我是Freshbooks的新手,我想要一些非常简单的东西。

我希望我的客户在字段中输入电子邮件或名字和姓氏,我希望我的PHP代码能够搜索到我的Freshbook帐户,如果我有该客户,如果我这样做,我希望我的表单可以提取所有帐户并粘贴到他们认为的输入区域。就像顾客的名字一样,将名字区域名称改为姓氏区域。

我试着用; http://code.google.com/p/freshbooks-php-library/

但我无法t figure it out and I don知道如何使用XML,所以有人可以帮助我吗?

1 个答案:

答案 0 :(得分:3)

查看API,我相信代码可能如下所示。请注意,这是完全未经测试的。

从客户对象开始

//new Client object
$client = new FreshBooks_Client();

使用列表方法获取具有特定电子邮件的用户

//listing function definition void   listing  ( &$rows,  &$resultInfo, [ $page = 1], [ $perPage = 25], [ $filters = array()])
//get projects, 25 per page, page 1, where project belong to client email x@x.x
$client->listing($rows,$resultInfo,1,25,array('email'=>'x@x.x'));

//dump result data
print_r($rows);
print_r($resultInfo);

使用列表方法获取具有特定用户名的用户

//listing function definition void   listing  ( &$rows,  &$resultInfo, [ $page = 1], [ $perPage = 25], [ $filters = array()])
//get projects, 25 per page, page 1, where project belong to client username test
$client->listing($rows,$resultInfo,1,25,array('username'=>'test'));

//dump result data
print_r($rows);
print_r($resultInfo);

希望它可以帮助你开始。