zoho accesstoken(以下简称token) 有效性是1个小时,而且在短时间内有重复生成token的限制(10分钟范围内最多生成10个token)
ress = zoho.crm.getOrgVariable("tokenstarttime");
//访问令牌
accessToken = zoho.crm.getOrgVariable("accesstoken");
info accessToken;
info ress;
info zoho.currenttime;
start_time = ress;
info start_time.unixEpoch();
aa = start_time.unixEpoch();
info zoho.currenttime.toString().unixEpoch();
bb = zoho.currenttime.toString().unixEpoch();
minutes = (bb - aa) / 60000;
info "minutes:" + minutes;
//判断时间差换算成分钟
if(minutes > 59.99)
{
tokenMap = Map();
tokenMap.put("refresh_token","1000.683ca6a2f4859399a8215b62f50463c3.553063c9040b8aaf0bfd117c15254c95");
tokenMap.put("client_id","1000.ZDAF0XH9OD7VQ8BO4LQ86PBNSSMXSZ");
tokenMap.put("client_secret","b174e63517ff81fd802ee864d85d6e821edb61bbfd");
tokenMap.put("grant_type","refresh_token");
info accessToken;
valueMap = Map();
valueMap.put("apiname","accesstoken");
valueMap.put("value",accessToken);
resp = zoho.crm.invokeConnector("crm.set",valueMap);
//设置刷新令牌日期
valueMapdate = Map();
valueMapdate.put("apiname","tokenstarttime");
valueMapdate.put("value",zoho.currenttime);
resp = zoho.crm.invokeConnector("crm.set",valueMapdate);
info resp;
}
else
{
//执行传输数据
datamap = Map();
datamap = Map();
datamap.put("key", "value");
datamap.put("key1", "value1");
//etcc..
insertres = invokeurl
[
type :POST
parameters:datamap.toString()
headers:{"Authorization":"Zoho-oauthtoken " + accessToken}
];
}