Thursday, November 27, 2014

c# google calendar v3 api

hi to all,


i had make an exe app witch loads data from an sql server and adds the events to the google calendar.


my program used to work just fine, but now just cannot connect because of v3.


my code:



class GooCal
{
public void cn(string user,
string pass,
string title,
string descr,
string where,
DateTime from,
DateTime to,
int rem
)
{
string appName = "MyCompany-MyApp-v1.0";
string userName = user; // google calendar login
string password = pass; // google calendar password

// connect to the calendar service
CalendarService service = new CalendarService(appName);
service.setUserCredentials(userName, password);


//service.setUserCredentials("Username", "Password");
EventEntry entry = new EventEntry();

// Set the title and content of the entry.
entry.Title.Text = title;
entry.Content.Content = descr;

// Set a location for the event.
Where eventLocation = new Where();
eventLocation.ValueString = where;
entry.Locations.Add(eventLocation);

When eventTime = new When(from, to);
entry.Times.Add(eventTime);

Reminder reminder = new Reminder();
reminder.Minutes = rem;
reminder.Method = Reminder.ReminderMethod.alert;
eventTime.Reminders.Add(reminder);

Uri postUri = new Uri("http://ift.tt/123cHPt;);


EventQuery myQuery1 = new EventQuery(postUri.ToString());
myQuery1.StartTime = from;
myQuery1.EndTime = to;
myQuery1.Query = title;// +" " + descr;

//entry.Content.Content

EventFeed myResultsFeed1 = service.Query(myQuery1);

if (myResultsFeed1.Entries.Count > 0)
{
AtomEntry firstMatchEntry = myResultsFeed1.Entries[0];
firstMatchEntry.Delete();
}
AtomEntry insertedEntry = service.Insert(postUri, entry);
}
}

where can i find and example of google v3?


Mind that i do not want any opening of authentification window because it supposed to work as a service.


thanks in advance


No comments:

Post a Comment