1

我目前正在尝试获取所有 Clarizen 活动项目的列表,以便我可以修改其任务的一些属性。我已经阅读了 Clarizen API,但它没有太多关于 PHP 查询的信息。到目前为止,我设法做的是查询所有项目,然后一一测试它们的状态。实际上,这不是一个好方法,因为我有数千个项目,并不是所有项目都一次列出。这是代码:

//LOGIN PROCCESS
$soapUrl = 'https://api.clarizen.com/v1.0/Clarizen.svc?WSDL';
$soapApiUrl = 'http://clarizen.com/api';

$soapConfig = array('exceptions' => 1);
$request = array();
$params = array(
    'userName' => $username,
    'password' => $password
);


$client = new SoapClient($soapUrl, $soapConfig);
$response = $client->Login($params);
$sessionId = $response->LoginResult->SessionId;
$userId = $response->LoginResult->UserId;

//Create a SOAP header containing the session ID for future requests    
$header = new SoapHeader($soapApiUrl, 'Session', array("ID"=>$sessionId));
$client->__setSoapHeaders($header);

//Create a Query object
$userQuery = new stdClass();
//Set the name of the entity type you are querying
$userQuery->TypeName = 'Project';
//Select the fields you want retrieved from that entity
$userQuery->Fields = array('Name', 'State');


/* Doesnt work...*/
/*
$userQuery->Where = new stdClass();
$userQuery->Where->LeftExpression = new stdClass();
$userQuery->Where->LeftExpression->FieldName = 'State';
$userQuery->Where->Operator = 'Equal';
$userQuery->Where->RightExpression = new stdClass();
$userQuery->Where->RightExpression->Value = new stdClass();
$userQuery->Where->RightExpression->Value->TypeName = 'State';
$userQuery->Where->RightExpression->Value->Value = 'Active';
*/
$request[] = new SoapVar($userQuery, SOAP_ENC_OBJECT, 'EntityQuery', 'http://clarizen.com/api/queries');

//Execute the request
$result = $client->Execute(array("request"=>$request));

3个问题如下:

  • 使用“WHERE”子句在 PHP 中查询的正确方法是什么
  • 如何获取该项目的任务,然后为它创建一个秒表。
  • 如何继续查询直到 hasMore 标志为 0,或者有没有办法一次获取整个东西?

提前致谢。

4

0 回答 0