Google calendar 是google一项日程管理服务,可以方便的组织、安排日程,可以为我们的日常生活带来极大地便利,并它不但可以通过email来提醒日程,也可以通过短信来通知。
因此可以利用它开发一些有趣的应用。
Google日历官方提供里.net sdk 可以方便我们的开发工作
http://code.google.com/apis/calendar/docs/2.0/developers_guide_dotnet.html
相关类库的说明
http://code.google.com/p/google-gdata/
一、 首先要有google的账号,并且开启了日历功能,在设置中填上自己手机号,然后要设置通知方式。
二、 现在就开始编写代码了
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click( object sender, EventArgs e)
{
string userName = "" ; // google账户
string passWord = "" ; // 密码
string postUrl = " https://www.google.com/calendar/feeds/default/private/full " ;
CalendarQuery query = new CalendarQuery(postUrl);
CalendarService service = new CalendarService( " calendar " );
// 设置用户名密码
service.setUserCredentials(userName, passWord);
EventEntry entry = new EventEntry();
// entry = null;
// Set the title and content of the entry.
entry.Title.Text = " Tennis with Beth " ; // 标题
entry.Content.Content = " Meet for a quick lesson. " ; // 内容
// Set a location for the event.
Where eventLocation = new Where();
eventLocation.ValueString = " South Tennis Courts " ;
entry.Locations.Add(eventLocation);
When eventTime = new When(DateTime.Now.AddMinutes( 2 ), DateTime.Now.AddHours( 2 ));
entry.Times.Add(eventTime); // 提前两秒
entry.Reminder = new Reminder { Minutes = 1 , Method = Reminder.ReminderMethod.sms }; // 发送方式
service.Insert( new Uri(postUrl), entry);
}
}
}
三、 用途
1、 在刚开学几周里,大多数同学都会记不清楚,每天在哪个教室上课。这时可以编写个软件,通过这个软件向谷歌日历导入一个月的课程信息,并且设置为每天早上向你的手机发送上教师的信息,这样再也不会找不着教室了。
如果你有台服务器,那么用处就更大。让这软件每天在服务器上一直运行。
1、 每天获取天气信息发送至手机,这样每月就省了不少钱了。
2、 使用它时刻监视股票信息,黄金,期货,外汇等信息,不错过任何时机。
3、 邮箱邮件短信通知,邮箱收到邮件发送短信通知。
4、 害怕别人乱动自己的电脑,使用软件记录他的详细操作信息,一切情况了若指掌。
其实还有更多功能有待大家发掘,有什么好主意请告诉我。