有空科技--开发文档中心

[日历]创建/更新

接口功能描述:

1、指定应用ClientKey下某一用户UserCode的本地日历创建,如果之前该应用下用户UserCode不存在则同时创建该用户帐号;
2、指定应用ClientKey下某一用户UserCode的本地日历编辑;
3、指定应用ClientKey下某一用户UserCode向第三方渠道创建日历,该第三方渠道帐号必须是已存在的;
4、指定应用ClientKey下某一用户UserCode向第三方渠道编辑日历。
日历名称请谨记尊重文明,勿使用攻击或侮辱性词汇。

接口地址:

环境 地址
正式环境 https://open.atimer.cn/v1/allinone/putcalendar
沙箱环境 https://sandbox.atimer.cn/v1/allinone/putcalendar

入参规范:

名称 类型 必须 描述
Client Client 系统参数,开发者调用接口向有空日程云传递的客户端信息
Calendar Calendar 业务参数,日历信息

公共请求参数Client:

名称 类型 是否必须 范例值 描述
ClientKey String 有空沙箱创建好的测试帐号,开发者可以在沙箱环境直接调用
key:UK155728046140bc
secret:f2af3c18606d4df59f865e8b80928510
有空日程云分配给应用的ClientKey
sign String 见算法 API输入参数签名结果,签名算法介绍请点击这里
UserCode String(100) 123,ABC23 开发者所属平台的用户编号,可以是任意合法符号
timestamp String 1558349646 时间戳,有空日程云 API服务端允许客户端请求最大时间误差3分钟

请求参数Calendar:

名称 类型 是否必须 范例值 描述
CalendarId String(500) abc 日历ID。修改时必填,新建时该字段由有空日程云或第三方渠道自动生成。
CalendarName String(200) 我的第一个主题 日历名称,在有空日程云平台又称为主题名称
ProfileId String(50) 系统自动生成 日历所属平台标识ID。
要获取到该参数:1、绑定第三方渠道帐户;2、getview接口返回集合Profiles中查找
CalendarReadonly bool 默认值:false 日历是否只读
CalendarPrimary bool 默认值:false 是否是主日历
IsPublic bool 默认值:false 是否公开
Tags String(100) 如:娱乐,聚会 标签
CalendarIcon String(150) 如:icon-home 日历图标
CalendarColor String(20) 如:blue_bg-info 日历颜色

入参重要参数组合说明:

CalendarId CalendarName ProfileId 描述
只传CalendarName,则向企业应用下用户主帐号创建新日历
传CalendarId和CalendarName,则对指定的日历(calendarId)进行CalendarName修改
传CalendarName和ProfileId,则对指定的第三方日历渠道(ProfileId)创建以CalendarName命名的新日历
传CalendarName、ProfileId和CalendarId,则对指定的第三方日历渠道(ProfileId)下的已有日历(CalendarId)进行CalendarName修改

出参规范:

{
   Success: true,
   Error: {
	// 包含 code 和 Description
 },
   Data: {
	// 下表解释
   }
}
									

输出参数:

名称 类型 范例值 描述
CalendarId String(500) 如:ed8119d35e8549059d30e847ccde81d3 日历ID

示例代码:

//JAVA示例代码部分							
// Calendar参数
Map calendar = new HashMap();
calendar.put("CalendarId", "");//主题日历ID,编辑时必填
calendar.put("CalendarName", "JAVA示例");//主题日历名称,必填
calendar.put("CalendarIcon", "");//主题日历图标,选填
calendar.put("CalendarColor", "");//主题日历颜色,选填
calendar.put("ProfileId", "");//主题日历所属第三方ID,选填
calendar.put("ProviderName", "");//主题日历所属第三方名称,选填,如ProfileId不为空,则必填
// Client参数
Map client = new HashMap();
client.put("ClientKey", "UK155728046140bc");//应用Key
client.put("UserCode", "xxxxxxxx");
String timestamp = String.valueOf(new Date().getTime()/1000);
client.put("Timestamp", timestamp);// 请求时间戳,3分钟有效
client.put("Sign", Md5Util.getMD5Code("key=UK155728046140bc&secret=f2af3c18606d4df59f865e8b80928510&timestamp="+timestamp+""));// 签名,MD5需要自己处理
//请求参数
Map map = new HashMap();
map.put("Client", client);
map.put("Calendar", calendar);
String result = new RestTemplate().postForObject("https://sandbox.atimer.cn/v1/allinone/putcalendar", map, String.class);
System.out.println(result);
											
<?php
/**
 * 创建、更新日历
 * */
$client = array();
$clientKey = "UK155728046140bc";
$secret = "f2af3c18606d4df59f865e8b80928510";
$url = "https://sandbox.atimer.cn/v1/allinone/putcalendar"; //沙箱环境url
$userCode = 'php001';  //测试
$time = time();
//Client 参数:
$client = [
    'ClientKey' => $clientKey,
    'Timestamp' =>$time,
    'Sign' => md5(http_build_query(['key'=>$clientKey,'secret'=>$secret,'timestamp'=>$time])),//签名
    'UserCode' => $userCode  //开发者用户编号
];
//Calendar 参数:
$calendar = [
    'CalendarName' => "创建日历",
];
//组装请求参数:
$param = [
    'Client' => $client,
    'Calendar' => $calendar
];
$requestDate = json_encode($param);
//curl请求
//初始化
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, '0');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, '0');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestDate);
$data = curl_exec($curl);
curl_close($curl);
echo $data;												
?>											
											
//请求参数
var timestamp = DateTime.Now.DateTimeToTimespan() + "";//时间戳
var ori = $"key=UK155728046140bc&secret=f2af3c18606d4df59f865e8b80928510&timestamp=" + timestamp;
var sign = ori.Md5();//签名Md5加密
var request1 = new
	{
		Client = new
		{
			ClientKey = "UK155728046140bc",//应用key
			Timestamp = "timestamp"// 请求时间戳,3分钟有效
			Sign = "sign"//签名
			UserCode = "dotnet001"//用户编号
		},
		Calendar = new
		{
			CalendarName = "创建日历"
		}
	};
string url = "https://sandbox.atimer.cn/v1/allinone/putcalendar";
string postData = request1.ObjToJson();
WebRequest request = WebRequest.Create(url);
request.Method = "Post";
request.ContentType = "application/x-www-form-urlencoded";
byte[] postBytes = Encoding.UTF8.GetBytes(postData);
request.ContentLength = Encoding.UTF8.GetBytes(postData).Length;
StreamWriter sw = new StreamWriter(request.GetRequestStream());
sw.Write(postData);
sw.Flush();
WebResponse response = request.GetResponse();
Stream s = response.GetResponseStream();
StreamReader sr = new StreamReader(s, Encoding.GetEncoding("gb2312"));
string str = sr.ReadToEnd();
sw.Dispose();
sw.Close();
sr.Dispose();
sr.Close();
s.Dispose();
s.Close();  
											
//JS部分代码
//需要引入jquery.min.js和jquery.md5.js
var requestObj = {};
var calendarObj = {};
calendarObj.CalendarId = "";//主题日历ID,编辑时必填
calendarObj.CalendarName = "JS示例";//主题日历名称,必填
calendarObj.CalendarIcon = "";//主题日历图标,选填
calendarObj.CalendarColor = "";//主题日历颜色,选填
calendarObj.ProfileId = "";//主题日历所属第三方ID,选填
calendarObj.ProviderName = "";//主题日历所属第三方名称,选填,如ProfileId不为空,则必填
requestObj.Calendar = calendarObj;
var clientObj = {};
clientObj.ClientKey = "UK155728046140bc";//应用Key
clientObj.UserCode = "xxxxxxxx";//开发者用户编号
clientObj.Timestamp = new Date().getTime()/1000;//请求时间戳。3分钟之内有效
clientObj.Sign = $.md5("key="+clientObj.ClientKey+"&secret=f2af3c18606d4df59f865e8b80928510&timestamp="+timestamp+"");//请求的签名
requestObj.Client = clientObj;
$.post("https://sandbox.atimer.cn/v1/allinone/putcalendar",requestObj,function(result){
	console.log(result);
}); 
											

响应示例:

{
    "Success": true,
    "Error": null,// 有错误时包含 code 和 Description
    "Data": {
        "CalendarId": "ed8119d35e8549059d30e847ccde81d3"//putcalendar接口返回值为CalendarId,其他接口返回各不相同
}												
											

案例1:创建日历

{
    "Client": {
        "ClientKey": "UK155728046140bc",
        "Timestamp": 1560390163,
        "Sign": "3b2c5181688371335ca691c8b797d09b",
        "UserCode": "cs001"
    },
    "Calendar": {
        "CalendarName": "本地日历",
        "CalendarIcon": "icon-shared",
        "CalendarColor": "#111"
    }
}									
										
{
    "Success": true,
    "Error": null,
    "Data": {
        "CalendarId": "de5ced8b69234185a1b8da506606e7c3"
    }
}												
										

案例2:修改日历

{
    "Client": {
        "ClientKey": "UK155728046140bc",
        "Timestamp": 1560390163,
        "Sign": "3b2c5181688371335ca691c8b797d09b",
        "UserCode": "cs001"
    },
    "Calendar": {
        "CalendarId": "de5ced8b69234185a1b8da506606e7c3"
        "CalendarName": "本地日历修改",
        "CalendarIcon": "icon-shared",
        "CalendarColor": "#111"
    }
}									
										
{
    "Success": true,
    "Error": null,
    "Data": {
        "CalendarId": "de5ced8b69234185a1b8da506606e7c3"
    }
}												
										

案例3:创建第三方日历

{
    "Client": {
        "ClientKey": "UK155728046140bc",
        "Timestamp": 1560389891,
        "Sign": "e2f64d44c169b55e1e6a7c5e6b7b6328",
        "UserCode": "cs001"
    },
    "Calendar": {
        "CalendarName": "创建第三方日历",
        "ProfileId": "2649fb89e5d541c7"
    }
}									
										
{
    "Success": true,
    "Error": null,
    "Data": {
        "CalendarId": "AQMkADAwATM3ZmYAZS0xZjYyLWEyNmQtMDACLTAwCgBGAAADjd_Vnf-En0yFrPumMpSQOwcAWxm3-qkho0yIHjuCRT62nwAAAgEGAAAAWxm3-qkho0yIHjuCRT62nwAAAD0NYMIAAAA="
    }
}												
										

案例4:修改第三方日历名称

{
    "Client": {
        "ClientKey": "UK155728046140bc",
        "Timestamp": 1560389891,
        "Sign": "e2f64d44c169b55e1e6a7c5e6b7b6328",
        "UserCode": "cs001"
    },
    "Calendar": {
        "CalendarId": "AQMkADAwATM3ZmYAZS0xZjYyLWEyNmQtMDACLTAwCgBGAAADjd_Vnf-En0yFrPumMpSQOwcAWxm3-qkho0yIHjuCRT62nwAAAgEGAAAAWxm3-qkho0yIHjuCRT62nwAAADo9SRcAAAA=",
        "CalendarName": "第三方日历",
        "ProfileId": "2649fb89e5d541c7"
    }
}									
										
{
    "Success": true,
    "Error": null,
    "Data": {
        "CalendarId": "AQMkADAwATM3ZmYAZS0xZjYyLWEyNmQtMDACLTAwCgBGAAADjd_Vnf-En0yFrPumMpSQOwcAWxm3-qkho0yIHjuCRT62nwAAAgEGAAAAWxm3-qkho0yIHjuCRT62nwAAAD0NYMIAAAA="
    }
}