Errors with Remote API
Errors with Remote API
Can you help me figure this one out?
Error:
RESULT=FALSE ERROR_CODE=2841 WARNING=Unable to import content
My code:
<form method="POST" id="frmZohoEdit" action="http://export.writer.zoho.com/remotedoc.im?apikey=9e7a4165451bcb2f828cf1089e050e04&output=editor" target="_blank">
<input type="hidden" name="id" value="!#[this.instance_id]#!">
<input type="hidden" name="url" value="http://!#[system.domain]#!!#[this.file_link]#!">
<input type="hidden" name="saveurl" value="!#[PAGE_URL_108]#!&action=SaveFromZoho&edit=!#[this.instance_id]#!">
<input type="hidden" name="filename" id="txtZohoFilename" value=""><!--supported formats : .doc, .rtf, .odt, .sxw, .html, .txt-->
<input type="hidden" name="format" id="txtZohoFormat" value="">
</form>
<script>
function editWithZoho(strFileLocation,strFilename) {
//http://writer.zoho.com/public/help/zohoapi/noband#RemoteAPI http://writer.zoho.com/public/help/zohoapi/fullpage#RemoteAPI
var strCurrentFileName = strFilename;
var iExtLoc = strCurrentFileName.length;
while(iExtLoc>-1) {
if(strCurrentFileName.substr(iExtLoc,1) == '.') break;
iExtLoc--;
}
var strExtension = strCurrentFileName.substr(iExtLoc+1).toLowerCase();
//alert(strCurrentFileName);
//alert(strExtension);
var arrFormatURL = new Array();
arrFormatURL['doc'] = 'http://export.writer.zoho.com/remotedoc.im?apikey=9e7a4165451bcb2f828cf1089e050e04&output=editor';
arrFormatURL['rtf'] = 'http://export.writer.zoho.com/remotedoc.im?apikey=9e7a4165451bcb2f828cf1089e050e04&output=editor';
arrFormatURL['odt'] = 'http://export.writer.zoho.com/remotedoc.im?apikey=9e7a4165451bcb2f828cf1089e050e04&output=editor';
arrFormatURL['sxw'] = 'http://export.writer.zoho.com/remotedoc.im?apikey=9e7a4165451bcb2f828cf1089e050e04&output=editor';
arrFormatURL['html'] = 'http://export.writer.zoho.com/remotedoc.im?apikey=9e7a4165451bcb2f828cf1089e050e04&output=editor';
arrFormatURL['txt'] = 'http://export.writer.zoho.com/remotedoc.im?apikey=9e7a4165451bcb2f828cf1089e050e04&output=editor';
arrFormatURL['xls'] = 'http://sheet.zoho.com/remotedoc.im?apikey=9e7a4165451bcb2f828cf1089e050e04&output=editor';
arrFormatURL['sxc'] = 'http://sheet.zoho.com/remotedoc.im?apikey=9e7a4165451bcb2f828cf1089e050e04&output=editor';
arrFormatURL['pdf'] = 'http://sheet.zoho.com/remotedoc.im?apikey=9e7a4165451bcb2f828cf1089e050e04&output=editor';
arrFormatURL['ppt'] = 'http://show.zoho.com/remotedoc.im?apikey=9e7a4165451bcb2f828cf1089e050e04&output=editor';
arrFormatURL['pps'] = 'http://show.zoho.com/remotedoc.im?apikey=9e7a4165451bcb2f828cf1089e050e04&output=editor';
if(arrFormatURL[strExtension] !== undefined) {
$('txtZohoFilename').value = strFilename;
$('txtZohoFormat').value = strExtension;
o = $('frmZohoEdit');
o.action = arrFormatURL[strExtension];
o.submit();
//RESULT=FALSE ERROR_CODE=2841 WARNING=Unable to import content
//http://dev.entrecore.com/sys/nl/ai.esp?cid=98ae845ecc2747abc9db3ab9e4510cdb&iid=108&taf=0&action=LoadEmailAttachment&id=202
} else {
alert('The extention "'+strExtension+'" is not supported by Zoho');
}
}
</script>
<input type="button" onclick="editWithZoho("http://dev.entrecore.com/sys/nl/ai.esp?cid=98ae845ecc2747abc9db3ab9e4510cdb&iid=108&taf=0&action=LoadEmailAttachment&id=202","Silver Cup 9.14.07 Meeting Tasks.xls")" value="Edit"/>
Code on the load attachment page:
<?php
if(eas_get_value("URL_STRING.action") == 'LoadEmailAttachment') {
$bHideAfter = false;
$strQuery = <<<QUERY
SELECT a.*
FROM binder_!#[binder_19]#! AS a
JOIN binder_!#[binder_18]#! AS m ON a.message_id = m.message_id
WHERE a.instance_id = '!#[URL_STRING.id]#!'
QUERY;
$r = eas_query($strQuery);
$att = pg_fetch_assoc($r->r);
$data = $att['data'];
if($att['encoding']=='base64'){
$data = base64_decode($data);
}elseif($att['encoding']=='quoted-printable'){
$data = quoted_printable_decode($data);
}
header("Content-type: {$att['content_type']}");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Cache-control: private");
header("Pragma: no-cache");
//header("Content-Type: application/force-download");
//header("Content-Type: application/octet-stream" );
header("Content-Length: ". strlen( $data ) );
header("Content-Disposition: attachment; FileName=\"{$att['file_name']}\"");
print $data;
}
?>