ZohoWriter API deadend

ZohoWriter API deadend

I'm trying to use the code below to call the writer.getDocuments method, but I am getting :

<?xml version="1.0" encoding="UTF-8" ?><methodResponse><error><errorCode>1401</errorCode><message>The username and password is wrong</message></error></methodResponse>


Code :

$client = curl_init("http://www.writer.zoho.com" . "/api?ticketid=" . $ticketid . "&apikey=" . $apikey);
curl_setopt($client,CURLOPT_RETURNTRANSFER,1);
curl_setopt($client,CURLOPT_POST,1);
curl_setopt($client,CURLOPT_URL,"http://www.writer.zoho.com" . "/api?ticketid=" . $ticketid . "&apikey=" . $apikey);
curl_setopt($client,CURLOPT_HTTPHEADER,array('Content-type:text/xml'));

$payload = '<?xml version="1.0" encoding="UTF-8"?>'
. '<methodCall>'
. '<methodName>writer.getDocuments</methodName>'
. '<params>'
. '<param>'
. '<value>'
. '<struct>'
. '<member>'
. '<name>fromindex</name>'
. '<value><int>2</int></value>'
. '</member>'
. '<member>'
. '<name>noofdocstoshow</name>'
. '<value><long>6</long></value>'
. '</member>'
. '</struct>'
. '</value>'
. '</param>'
. '</params>'
. '</methodCall>';

curl_setopt($client,CURLOPT_POSTFIELDS,$payload);
curl_setopt($client,CURLOPT_USERPWD,"{$username}:{$password}");

header('Content-type:text/xml');
echo curl_exec($client);
































Are there any authentication prior to the method call?

Thanks