Page 1 of 1

Starting point for php API?

PostPosted: Tue May 05, 2009 8:14 pm
by tfeathers
I need a doc to walk me through how to even start getting the API to work. I still can't find the sample client code... Anyone that can help me?

PostPosted: Wed May 06, 2009 10:42 am
by fman
have you browsing your TL installation?
see inside lib\api\ folder

PostPosted: Wed May 06, 2009 1:46 pm
by tfeathers
Thank you very much. Now I have a question about the php scripts? When I run them from command line on my location machine. I get IXR_Client not found. Am I missing something on my php install? Should these script be run on the server where testlink is installed?

PostPosted: Wed May 06, 2009 4:03 pm
by fman
you need to have part of TL installation i.e. XML-RPC library

PostPosted: Wed May 06, 2009 4:47 pm
by tfeathers
Isn't that taken care of by the require statement?
require_once dirname(__FILE__) . THIRD_PARTY_CODE . '/xml-rpc/class-IXR.php';

PostPosted: Thu May 07, 2009 10:35 am
by fman
yes but you have to have this ON HOST from where you are trying to run client

PostPosted: Thu May 07, 2009 3:21 pm
by tfeathers
Thank you very much. It is all working now. Is there a way for me to use php -a <scriptname>.php to only print out the data I need to the command line?

For example,

$args["testplanid"]='7';
$args["testcaseexternalid"]='Test-2';

$debug=true;
echo $unitTestDescription;
$client = new IXR_Client($server_url);
$client->debug=$debug;

new dBug($args);
if(!$client->query("tl.{$method}", $args))
{
echo "something went wrong - " . $client->getErrorCode() . " - " . $client->getErrorMessage();
$response=null;
}
else
{
$response=$client->getResponse();
}

I want to parse $response as a string and get the date I need. Not print it out using new dBug($response);

PostPosted: Thu May 07, 2009 4:28 pm
by fman
comment out dBug() calls
in anyway examples are thinked to be runned NOT FROM COMMAND LINE
and I've never tested it in this condition