এমন একটি অ্যাপের কথা ভাবুন যা ব্যবহারকারীদের সেরা হাইকিং রুট খুঁজে পেতে সাহায্য করে। হাইকিং প্ল্যানটি ক্যালেন্ডার ইভেন্ট হিসেবে যোগ করার মাধ্যমে, ব্যবহারকারীরা অটোমেটিক সংগঠিত থাকার ক্ষেত্রে অনেক সাহায্য পান। Google Calendar তাদের প্ল্যান শেয়ার করতে সাহায্য করে এবং এই বিষয়ে তাদের রিমাইন্ডার দেয় যাতে তারা কোনও চাপ ছাড়াই প্রস্তুতি নিতে পারে। এছাড়াও, Google প্রোডাক্টের সহজ ইন্টিগ্রেশনের জন্য, Google Now তাদের বের হওয়ার সময় সম্পর্কে পিং করে এবং Google Maps তাদের মিটিংয়ের জায়গায় সময়মতো পৌঁছাতে সাহায্য করে।
এই নিবন্ধে ক্যালেন্ডার ইভেন্ট তৈরি করা এবং ব্যবহারকারীর ক্যালেন্ডারে তা যোগ করার পদ্ধতি সম্পর্কে ব্যাখ্যা করা হয়েছে।
একটি ইভেন্ট যোগ করুন
ইভেন্ট তৈরি করতে, অন্তত এইসব প্যারামিটার
প্রদান করে events.insert() পদ্ধতি
কল করুন:
calendarIdহল ক্যালেন্ডার আইডেন্টিফায়ার এবং এটি হয় যে ক্যালেন্ডারে ইভেন্ট তৈরি করতে হবে তার ইমেল আইডি হতে পারে অথবা বিশেষ কীওয়ার্ড'primary'হতে পারে যা লগ-ইন করা ব্যবহারকারীর প্রাথমিক ক্যালেন্ডার ব্যবহার করবে। আপনি যে ক্যালেন্ডার ব্যবহার করতে চান সেটির ইমেল আইডি না জানলে, আপনি Google Calendar ওয়েব UI-এর ক্যালেন্ডার সেটিংসে ("ক্যালেন্ডার অ্যাড্রেস" বিভাগে) অথবাcalendarList.list()কলের ফলাফলে এটি চেক করতে পারেন।eventহল ইভেন্ট যা শুরু ও শেষের মতো সব প্রয়োজনীয় বিবরণ সহ তৈরি করতে হবে। শুধুমাত্র দুটি ফিল্ড পূরণ করতে হবে, সেগুলি হলstartএবংendসময়। ইভেন্ট ফিল্ডের সম্পূর্ণ সেটের জন্যeventরেফারেন্স দেখুন।
ইভেন্ট তৈরি করতে, আপনাকে:
- আপনার OAuth স্কোপ
https://www.googleapis.com/auth/calendar-এ সেট করুন যাতে ব্যবহারকারীর ক্যালেন্ডারে আপনার এডিট অ্যাক্সেস থাকে। - যাচাই করা ব্যবহারকারীর কাছে আপনার দেওয়া
calendarIdসহ ক্যালেন্ডারে রাইট অ্যাক্সেস আছে কিনা তা নিশ্চিত করুন (যেমন,calendarId-এর জন্যcalendarList.get()কল করে এবংaccessRoleচেক করে)।
ইভেন্ট মেটাডেটা যোগ করুন
আপনি ক্যালেন্ডার ইভেন্ট তৈরি করার সময় ইভেন্ট মেটাডেটা যোগ করতে পারেন। তৈরি করার সময়
মেটাডেটা যোগ না করার সিদ্ধান্ত নিলে, আপনি events.update() ব্যবহার করে
অনেক ফিল্ড আপডেট করতে পারবেন; তবে, ইভেন্ট আইডির মতো
কিছু ফিল্ড শুধুমাত্র events.insert() অপারেশনের
সময় সেট করা যাবে।
- লোকেশন
- লোকেশন ফিল্ডে ঠিকানা যোগ করলে "বের হওয়ার সময়" বা দিকনির্দেশ সহ ম্যাপ দেখানোর মতো ফিচার চালু হয়ে যায়।
- ইভেন্ট আইডি
- ইভেন্ট তৈরি করার সময়, আপনি নিজের ইভেন্ট আইডি তৈরি করার বিকল্প বেছে নিতে পারেন যা আমাদের ফর্ম্যাট সংক্রান্ত প্রয়োজনীয়তা মেনে চলে। এটি আপনাকে Google Calendar-এর ইভেন্টের সাথে আপনার লোকাল ডেটাবেসে এন্টিটি সিঙ্ক করে রাখতে দেয়। এছাড়াও, Calendar ব্যাকএন্ডে কোনও অপারেশন সফলভাবে সম্পূর্ণ হওয়ার পরে কোনও কারণে ব্যর্থ হলে, এটি ডুপ্লিকেট ইভেন্ট তৈরি হওয়া আটকায়। কোনও ইভেন্ট আইডি প্রদান করা না হলে, সার্ভার আপনার জন্য একটি আইডি তৈরি করে। আরও তথ্যের জন্য ইভেন্ট আইডি রেফারেন্স দেখুন।
- অংশগ্রহণকারী ব্যক্তি
- আপনার তৈরি করা ইভেন্ট একই ইভেন্ট আইডি সহ আপনার অন্তর্ভুক্ত করা অংশগ্রহণকারীদের
সব প্রাথমিক ক্যালেন্ডারে দেখা যায়। সাধারণত
(
sendUpdates="externalOnly"), Calendar শুধুমাত্র Google Calendar ব্যবহার করেন না এমন অংশগ্রহণকারীদের ইমেল বিজ্ঞপ্তি পাঠায়। সব অংশগ্রহণকারীকে বিজ্ঞপ্তি পাঠাতেsendUpdates-কে"all"-এ সেট করুন অথবা কোনও ইমেল বিজ্ঞপ্তি না পাঠাতে"none"-এ সেট করুন। আরও জানতে, একাধিক অংশগ্রহণকারী ব্যক্তি সহ ইভেন্ট দেখুন।
নিম্নলিখিত উদাহরণগুলি একটি ইভেন্ট তৈরি করা এবং এর মেটাডেটা সেট করা দেখায়:
খুলুন
// Refer to the Go quickstart on how to setup the environment:
// https://developers.google.com/workspace/calendar/quickstart/go
// Change the scope to calendar.CalendarScope and delete any stored credentials.
event := &calendar.Event{
Summary: "Google I/O 2015",
Location: "800 Howard St., San Francisco, CA 94103",
Description: "A chance to hear more about Google's developer products.",
Start: &calendar.EventDateTime{
DateTime: "2015-05-28T09:00:00-07:00",
TimeZone: "America/Los_Angeles",
},
End: &calendar.EventDateTime{
DateTime: "2015-05-28T17:00:00-07:00",
TimeZone: "America/Los_Angeles",
},
Recurrence: []string{"RRULE:FREQ=DAILY;COUNT=2"},
Attendees: []*calendar.EventAttendee{
&calendar.EventAttendee{Email:"lpage@example.com"},
&calendar.EventAttendee{Email:"sbrin@example.com"},
},
}
calendarId := "primary"
event, err = srv.Events.Insert(calendarId, event).Do()
if err != nil {
log.Fatalf("Unable to create event. %v\n", err)
}
fmt.Printf("Event created: %s\n", event.HtmlLink)
Java
// Refer to the Java quickstart on how to setup the environment:
// https://developers.google.com/workspace/calendar/quickstart/java
// Change the scope to CalendarScopes.CALENDAR and delete any stored
// credentials.
Event event = new Event()
.setSummary("Google I/O 2015")
.setLocation("800 Howard St., San Francisco, CA 94103")
.setDescription("A chance to hear more about Google's developer products.");
DateTime startDateTime = new DateTime("2015-05-28T09:00:00-07:00");
EventDateTime start = new EventDateTime()
.setDateTime(startDateTime)
.setTimeZone("America/Los_Angeles");
event.setStart(start);
DateTime endDateTime = new DateTime("2015-05-28T17:00:00-07:00");
EventDateTime end = new EventDateTime()
.setDateTime(endDateTime)
.setTimeZone("America/Los_Angeles");
event.setEnd(end);
String[] recurrence = new String[] {"RRULE:FREQ=DAILY;COUNT=2"};
event.setRecurrence(Arrays.asList(recurrence));
EventAttendee[] attendees = new EventAttendee[] {
new EventAttendee().setEmail("lpage@example.com"),
new EventAttendee().setEmail("sbrin@example.com"),
};
event.setAttendees(Arrays.asList(attendees));
EventReminder[] reminderOverrides = new EventReminder[] {
new EventReminder().setMethod("email").setMinutes(24 * 60),
new EventReminder().setMethod("popup").setMinutes(10),
};
Event.Reminders reminders = new Event.Reminders()
.setUseDefault(false)
.setOverrides(Arrays.asList(reminderOverrides));
event.setReminders(reminders);
String calendarId = "primary";
event = service.events().insert(calendarId, event).execute();
System.out.printf("Event created: %s\n", event.getHtmlLink());
জাভাস্ক্রিপ্ট
// Refer to the JavaScript quickstart on how to setup the environment:
// https://developers.google.com/workspace/calendar/quickstart/js
// Change the scope to 'https://www.googleapis.com/auth/calendar' and delete any
// stored credentials.
const event = {
'summary': 'Google I/O 2015',
'location': '800 Howard St., San Francisco, CA 94103',
'description': 'A chance to hear more about Google\'s developer products.',
'start': {
'dateTime': '2015-05-28T09:00:00-07:00',
'timeZone': 'America/Los_Angeles'
},
'end': {
'dateTime': '2015-05-28T17:00:00-07:00',
'timeZone': 'America/Los_Angeles'
},
'recurrence': [
'RRULE:FREQ=DAILY;COUNT=2'
],
'attendees': [
{'email': 'lpage@example.com'},
{'email': 'sbrin@example.com'}
],
'reminders': {
'useDefault': false,
'overrides': [
{'method': 'email', 'minutes': 24 * 60},
{'method': 'popup', 'minutes': 10}
]
}
};
const request = gapi.client.calendar.events.insert({
'calendarId': 'primary',
'resource': event
});
request.execute(function(event) {
appendPre('Event created: ' + event.htmlLink);
});
Node.js
// Refer to the Node.js quickstart on how to setup the environment:
// https://developers.google.com/workspace/calendar/quickstart/node
// Change the scope to 'https://www.googleapis.com/auth/calendar' and delete any
// stored credentials.
const event = {
'summary': 'Google I/O 2015',
'location': '800 Howard St., San Francisco, CA 94103',
'description': 'A chance to hear more about Google\'s developer products.',
'start': {
'dateTime': '2015-05-28T09:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'end': {
'dateTime': '2015-05-28T17:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'recurrence': [
'RRULE:FREQ=DAILY;COUNT=2'
],
'attendees': [
{'email': 'lpage@example.com'},
{'email': 'sbrin@example.com'},
],
'reminders': {
'useDefault': false,
'overrides': [
{'method': 'email', 'minutes': 24 * 60},
{'method': 'popup', 'minutes': 10},
],
},
};
calendar.events.insert({
auth: auth,
calendarId: 'primary',
resource: event,
}, function(err, event) {
if (err) {
console.log('There was an error contacting the Calendar service: ' + err);
return;
}
console.log('Event created: %s', event.htmlLink);
});
PHP
$event = new Google_Service_Calendar_Event(array(
'summary' => 'Google I/O 2015',
'location' => '800 Howard St., San Francisco, CA 94103',
'description' => 'A chance to hear more about Google\'s developer products.',
'start' => array(
'dateTime' => '2015-05-28T09:00:00-07:00',
'timeZone' => 'America/Los_Angeles',
),
'end' => array(
'dateTime' => '2015-05-28T17:00:00-07:00',
'timeZone' => 'America/Los_Angeles',
),
'recurrence' => array(
'RRULE:FREQ=DAILY;COUNT=2'
),
'attendees' => array(
array('email' => 'lpage@example.com'),
array('email' => 'sbrin@example.com'),
),
'reminders' => array(
'useDefault' => FALSE,
'overrides' => array(
array('method' => 'email', 'minutes' => 24 * 60),
array('method' => 'popup', 'minutes' => 10),
),
),
));
$calendarId = 'primary';
$event = $service->events->insert($calendarId, $event);
printf('Event created: %s\n', $event->htmlLink);
Python
# Refer to the Python quickstart on how to setup the environment:
# https://developers.google.com/workspace/calendar/quickstart/python
# Change the scope to 'https://www.googleapis.com/auth/calendar' and delete any
# stored credentials.
event = {
'summary': 'Google I/O 2015',
'location': '800 Howard St., San Francisco, CA 94103',
'description': 'A chance to hear more about Google\'s developer products.',
'start': {
'dateTime': '2015-05-28T09:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'end': {
'dateTime': '2015-05-28T17:00:00-07:00',
'timeZone': 'America/Los_Angeles',
},
'recurrence': [
'RRULE:FREQ=DAILY;COUNT=2'
],
'attendees': [
{'email': 'lpage@example.com'},
{'email': 'sbrin@example.com'},
],
'reminders': {
'useDefault': False,
'overrides': [
{'method': 'email', 'minutes': 24 * 60},
{'method': 'popup', 'minutes': 10},
],
},
}
event = service.events().insert(calendarId='primary', body=event).execute()
print 'Event created: %s' % (event.get('htmlLink'))
Ruby
event = Google::Apis::CalendarV3::Event.new(
summary: 'Google I/O 2015',
location: '800 Howard St., San Francisco, CA 94103',
description: 'A chance to hear more about Google\'s developer products.',
start: Google::Apis::CalendarV3::EventDateTime.new(
date_time: '2015-05-28T09:00:00-07:00',
time_zone: 'America/Los_Angeles'
),
end: Google::Apis::CalendarV3::EventDateTime.new(
date_time: '2015-05-28T17:00:00-07:00',
time_zone: 'America/Los_Angeles'
),
recurrence: [
'RRULE:FREQ=DAILY;COUNT=2'
],
attendees: [
Google::Apis::CalendarV3::EventAttendee.new(
email: 'lpage@example.com'
),
Google::Apis::CalendarV3::EventAttendee.new(
email: 'sbrin@example.com'
)
],
reminders: Google::Apis::CalendarV3::Event::Reminders.new(
use_default: false,
overrides: [
Google::Apis::CalendarV3::EventReminder.new(
reminder_method: 'email',
minutes: 24 * 60
),
Google::Apis::CalendarV3::EventReminder.new(
reminder_method: 'popup',
minutes: 10
)
]
)
)
result = client.insert_event('primary', event)
puts "Event created: #{result.html_link}"
ইভেন্টে Drive অ্যাটাচমেন্ট যোগ করা
আপনি নিজের ক্যালেন্ডার ইভেন্টে Google Drive
ফাইল অ্যাটাচ করতে পারবেন, যেমন Docs-এ মিটিং নোট, Sheets-এ বাজেট, Slides-এ প্রেজেন্টেশন বা অন্য কোনও
প্রাসঙ্গিক Google Drive ফাইল। আপনি events.insert()-এর মাধ্যমে কোনও ইভেন্ট তৈরি করার সময় বা পরে events.patch()-এর মতো আপডেটের অংশ হিসেবে
অ্যাটাচমেন্ট যোগ করতে পারবেন
কোনও ইভেন্টে Google Drive ফাইল অ্যাটাচ করার দুটি অংশ হল:
- Drive API Files রিসোর্স থেকে
ফাইল
alternateLinkURL,titleএবংmimeTypeপান, সাধারণতfiles.get()পদ্ধতির মাধ্যমে। - অনুরোধের প্রধান অংশে
attachmentsফিল্ড সেট করে এবংsupportsAttachmentsপ্যারামিটারtrue-এ সেট করে কোনও ইভেন্ট তৈরি বা আপডেট করুন।
নিচে দেওয়া কোডের উদাহরণ থেকে বোঝা যাবে যে আগে থেকে থাকা কোনও ইভেন্টে কীভাবে অ্যাটাচমেন্ট যোগ করার জন্য আপডেট করতে হবে:
Java
public static void addAttachment(Calendar calendarService, Drive driveService, String calendarId,
String eventId, String fileId) throws IOException {
File file = driveService.files().get(fileId).execute();
Event event = calendarService.events().get(calendarId, eventId).execute();
List<EventAttachment> attachments = event.getAttachments();
if (attachments == null) {
attachments = new ArrayList<EventAttachment>();
}
attachments.add(new EventAttachment()
.setFileUrl(file.getAlternateLink())
.setMimeType(file.getMimeType())
.setTitle(file.getTitle()));
Event changes = new Event()
.setAttachments(attachments);
calendarService.events().patch(calendarId, eventId, changes)
.setSupportsAttachments(true)
.execute();
}
PHP
function addAttachment($calendarService, $driveService, $calendarId, $eventId, $fileId) {
$file = $driveService->files->get($fileId);
$event = $calendarService->events->get($calendarId, $eventId);
$attachments = $event->attachments;
$attachments[] = array(
'fileUrl' => $file->alternateLink,
'mimeType' => $file->mimeType,
'title' => $file->title
);
$changes = new Google_Service_Calendar_Event(array(
'attachments' => $attachments
));
$calendarService->events->patch($calendarId, $eventId, $changes, array(
'supportsAttachments' => TRUE
));
}
Python
def add_attachment(calendarService, driveService, calendarId, eventId, fileId):
file = driveService.files().get(fileId=fileId).execute()
event = calendarService.events().get(calendarId=calendarId,
eventId=eventId).execute()
attachments = event.get('attachments', [])
attachments.append({
'fileUrl': file['alternateLink'],
'mimeType': file['mimeType'],
'title': file['title']
})
changes = {
'attachments': attachments
}
calendarService.events().patch(calendarId=calendarId, eventId=eventId,
body=changes,
supportsAttachments=True).execute()
ইভেন্টে ভিডিও ও ফোন কনফারেন্স যোগ করা
আপনি Hangouts এবং Google Meet কনফারেন্সের সাথে ইভেন্ট যুক্ত করতে পারেন যাতে আপনার ব্যবহারকারীরা ফোন কল বা ভিডিও কলের মাধ্যমে দূরবর্তী স্থানে থেকেও মিটিং করতে পারেন।
conferenceData ফিল্ডটি
আগে থেকে থাকা কনফারেন্সের বিবরণ পড়তে, কপি করতে এবং মুছে ফেলতে ব্যবহার করা যেতে পারে; এটি
নতুন কনফারেন্স তৈরি করার অনুরোধ করতেও ব্যবহার করা যেতে পারে। কনফারেন্সের বিবরণ তৈরি ও
পরিবর্তন করার অনুমতি দিতে, conferenceDataVersion অনুরোধের
প্যারামিটার 1-এ সেট করুন।
বর্তমানে তিন ধরনের conferenceData কাজ করে, যা
conferenceData.conferenceSolution.key.type দ্বারা চিহ্নিত করা হয়:
- গ্রাহকদের জন্য Hangouts (
eventHangout) - Google Workspace ব্যবহারকারীদের জন্য ক্লাসিক Hangouts
(বন্ধ করা হয়েছে;
eventNamedHangout) - Google Meet (
hangoutsMeet)
calendars এবং
calendarList সংগ্রহে
conferenceProperties.allowedConferenceSolutionTypes দেখে আপনি জানতে পারবেন যে কোনও ব্যবহারকারীর
প্রদত্ত ক্যালেন্ডারের জন্য কোন ধরনের কনফারেন্স কাজ করে। এছাড়াও,
ব্যবহারকারী তার নতুন তৈরি করা সব ইভেন্টের জন্য Hangouts তৈরি করতে চান কিনা তা আপনি
settings সংগ্রহে autoAddHangouts সেটিং চেক করে
জানতে পারবেন।
type ছাড়াও, conferenceSolution-এ name এবং
iconUri ফিল্ডও থাকে যা আপনি নিচে দেখানো কনফারেন্সিং সমাধানকে উপস্থাপন করতে ব্যবহার করতে পারেন:
জাভাস্ক্রিপ্ট
const solution = event.conferenceData.conferenceSolution;
const content = document.getElementById("content");
const text = document.createTextNode("Join " + solution.name);
const icon = document.createElement("img");
icon.src = solution.iconUri;
content.appendChild(icon);
content.appendChild(text);
আপনি নতুন তৈরি করা requestId-এর সাথে createRequest প্রদান করে কোনও ইভেন্টের জন্য নতুন কনফারেন্স তৈরি করতে পারবেন, যা র্যান্ডম string হতে পারে। কনফারেন্স অ্যাসিঙ্ক্রোনাসভাবে তৈরি করা হয়, তবে আপনার ব্যবহারকারীদের কী ঘটছে তা জানাতে আপনি সবসময় আপনার অনুরোধের স্ট্যাটাস চেক করতে পারেন।
যেমন, আগে থেকে থাকা ইভেন্টের জন্য কনফারেন্স জেনারেশনের অনুরোধ করতে:
জাভাস্ক্রিপ্ট
const eventPatch = {
conferenceData: {
createRequest: {requestId: "7qxalsvy0e"}
}
};
gapi.client.calendar.events.patch({
calendarId: "primary",
eventId: "7cbh8rpc10lrc0ckih9tafss99",
resource: eventPatch,
sendUpdates: "all",
conferenceDataVersion: 1
}).execute(function(event) {
console.log("Conference created for event: %s", event.htmlLink);
});
এই কলের তাৎক্ষণিক উত্তরে এখনও সম্পূর্ণ-পপুলেটেড
conferenceData নাও থাকতে পারে; এটি
স্ট্যাটাস
ফিল্ডে pending-এর স্ট্যাটাস কোড দ্বারা নির্দেশিত হয়। কনফারেন্সের তথ্য পূরণ করার পরে স্ট্যাটাস কোড পরিবর্তন হয়ে success হয়ে যায়। entryPoints ফিল্ডে আপনার ব্যবহারকারীদের ডায়াল করার জন্য কোন ভিডিও এবং
ফোন URI উপলভ্য আছে সেই সংক্রান্ত তথ্য থাকে।
আপনি যদি একই কনফারেন্সের বিবরণ সহ একাধিক ক্যালেন্ডার ইভেন্ট শিডিউল করতে চান, তাহলে আপনি একটি ইভেন্ট থেকে অন্য ইভেন্টে সম্পূর্ণ conferenceData কপি করতে পারেন।
নির্দিষ্ট কিছু পরিস্থিতিতে কপি করা কার্যকর হতে পারে। যেমন, ধরুন আপনি এমন একটি রিক্রুটিং অ্যাপ্লিকেশন ডেভেলপ করছেন যা প্রার্থী এবং ইন্টারভিউয়ারের জন্য আলাদা ইভেন্ট সেট-আপ করে—আপনি ইন্টারভিউয়ারের পরিচয় গোপন রাখতে চান, কিন্তু আপনি এটাও নিশ্চিত করতে চান যে সব অংশগ্রহণকারী একই কনফারেন্স কলে যোগ দিচ্ছেন।