इवेंट बनाएं

सोचिए कि कोई ऐसा ऐप्लिकेशन है जो हाइकिंग के सबसे अच्छे रास्ते ढूंढने में उपयोगकर्ताओं की मदद करता है. अपनी रिपोर्ट में हाइकिंग की योजना का इस्तेमाल किया है, तो उपयोगकर्ताओं को ठहरने में काफ़ी मदद मिलती है अपने-आप व्यवस्थित हो जाता है. Google Calendar की मदद से, वे सभी प्लान शेयर कर पाते हैं और उन्हें इसके बारे में याद दिलाता है, ताकि वे बिना किसी तनाव के तैयार रह सकें. साथ ही, इसके लिए धन्यवाद Google प्रॉडक्ट का आसान एकीकरण, Google अभी सेवा उन्हें आपका फ़ोन मीटिंग से बाहर निकलें और Google Maps उन्हें मीटिंग की जगह पर समय पर पहुंचा दे.

इस लेख में कैलेंडर इवेंट बनाने और उन्हें अपने उपयोगकर्ताओं की सदस्यता में जोड़ने का तरीका बताया गया है कैलेंडर.

इवेंट जोड़ें

एक इवेंट बनाने के लिए, events.insert() तरीका उपलब्ध है: कम से कम ये पैरामीटर:

  • calendarId, कैलेंडर का आइडेंटिफ़ायर है. यह ईमेल पता भी हो सकता है उस कैलेंडर का इस्तेमाल करें जिस पर इवेंट या विशेष कीवर्ड बनाना है 'primary', जो लॉग इन किए हुए उपयोगकर्ता के मुख्य कैलेंडर का इस्तेमाल करेगा. अगर आपने आपको अपने कैलेंडर का ईमेल पता नहीं पता है, तो इसे Google Calendar के वेब वर्शन में कैलेंडर की सेटिंग में देखा जा सकता है यूज़र इंटरफ़ेस (यूआई) ("कैलेंडर पता" सेक्शन में) या इसे ढूंढा जा सकता है इसकी वजह से calendarList.list() कॉल.
  • event एक ऐसा इवेंट है जिसे सभी ज़रूरी जानकारी के साथ बनाया जा सकता है, जैसे कि शुरू करना और खत्म करें. सिर्फ़ दो ज़रूरी फ़ील्ड हैं, start और end बार. ज़्यादा जानकारी के लिए, इवेंट के पूरे सेट के लिए event रेफ़रंस फ़ील्ड.

इवेंट बनाने के लिए, आपको ये काम करने होंगे:

  • अपने OAuth के दायरे को https://www.googleapis.com/auth/calendar पर सेट करें, ताकि आपके पास उपयोगकर्ता के कैलेंडर में बदलाव करने का ऐक्सेस है.
  • यह पक्का करें कि प्रमाणित उपयोगकर्ता के पास कैलेंडर में बदलाव करने का ऐक्सेस हो calendarId आपने दिया है (उदाहरण के लिए, कॉल करके calendarList.get() calendarId) और accessRole की जांच की जा रही है.

इवेंट का मेटाडेटा जोड़ें

कैलेंडर इवेंट बनाते समय, इवेंट का मेटाडेटा जोड़ा जा सकता है. हालांकि, ऐसा करना ज़रूरी नहीं है. अगर आपको बनाने के दौरान मेटाडेटा नहीं जोड़ना है, तो आप events.update(); हालांकि, कुछ फ़ील्ड, जैसे इवेंट आईडी को सिर्फ़ events.insert() कार्रवाई.

जगह

स्थान फ़ील्ड में पता जोड़ने से इस तरह की सुविधाएं सक्षम हो जाती हैं

"निकलने का समय" या फिर दिशा-निर्देशों के साथ मैप दिखाना.

इवेंट आईडी

इवेंट बनाते समय, अपने हिसाब से इवेंट आईडी जनरेट करने का विकल्प चुना जा सकता है

जो हमारी फ़ॉर्मैट की ज़रूरतों के हिसाब से होते हैं. इससे आपको इकाइयों को रखने की सुविधा मिलती है आपके लोकल डेटाबेस में, Google Calendar के इवेंट के साथ सिंक करते हैं. यह भी अगर कोई कार्रवाई बाद में पूरी नहीं होती है, तो डुप्लीकेट इवेंट बनाने से रोकता है यह कैलेंडर बैकएंड में लागू होता है. अगर नहीं इवेंट आईडी दिया जाता है, तो सर्वर आपके लिए एक इवेंट आईडी जनरेट करता है. इवेंट आईडी देखें संदर्भ देखें.

अतिथि

आपका बनाया गया इवेंट, इसके सभी मुख्य Google Calendar में दिखता है

शामिल किए गए मेहमानों को आपने उसी इवेंट आईडी से जोड़ा था. अगर आपने सेट किया है, तो sendNotifications से true तक शामिल करने का अनुरोध करने पर, मेहमानों को आपको इवेंट की ईमेल सूचना भी मिलेगी. के साथ इवेंट देखें एक से ज़्यादा लोगों के लिए गाइड ज़्यादा जानकारी देखें.

इन उदाहरणों में, इवेंट बनाने और उसका मेटाडेटा सेट करने के बारे में बताया गया है:

शुरू करें

// Refer to the Go quickstart on how to setup the environment:
// https://developers.google.com/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/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());

JavaScript

// Refer to the JavaScript quickstart on how to setup the environment:
// https://developers.google.com/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/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/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 में मीटिंग के नोट, बजट शीट, Slides में प्रज़ेंटेशन या कोई अन्य Google Drive में मौजूद काम की फ़ाइलों को आपके कैलेंडर इवेंट में सेव करने की सुविधा मिलती है. आप अटैचमेंट तब आज़माएं, जब आप इसकी मदद से इवेंट बनाएं events.insert() या इसके बाद के वर्शन अपडेट, जैसे कि events.patch() से

किसी इवेंट में, Google Drive की फ़ाइल अटैच करने के दो हिस्से हैं:

  1. से फ़ाइल alternateLink का यूआरएल, title, और mimeType पाएं आम तौर पर, Drive API फ़ाइलों के संसाधन files.get() तरीके का इस्तेमाल करें.
  2. अनुरोध में सेट किए गए 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:

  1. उपभोक्ताओं के लिए Hangouts (eventHangout)
  2. उपयोगकर्ताओं के लिए Google Workspace क्लासिक Hangouts (अब सेवा में नहीं है; eventNamedHangout)
  3. Google Meet (hangoutsMeet)

आप यह जान सकते हैं कि किसी कैलेंडर के लिए किस तरह का कॉन्फ़्रेंस काम करता है conferenceProperties.allowedConferenceSolutionTypes को देखकर उपयोगकर्ता ने calendars और calendarList कलेक्शन. आप यह भी कर सकते हैं जानें कि उपयोगकर्ता अपने सभी नए autoAddHangouts सेटिंग को चेक करके इवेंट बनाए settings संग्रह.

type के अलावा, conferenceSolution name और iconUri फ़ील्ड का इस्तेमाल, कॉन्फ़्रेंस का समाधान दिखाने के लिए किया जा सकता है, जैसा कि यहां दिखाया गया है नीचे दिया गया है:

JavaScript

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);

किसी इवेंट के लिए एक नई कॉन्फ़्रेंस बनाने के लिए, इसके साथ createRequest जोड़ें: जनरेट किया गया नया requestId, जो कोई भी रैंडम string हो सकता है. कॉन्फ़्रेंस बनाया गया है, लेकिन आप हमेशा अपने उपयोगकर्ताओं को बताएं कि क्या समस्या आ रही है.

उदाहरण के लिए, किसी मौजूदा इवेंट के लिए कॉन्फ़्रेंस जनरेट करने का अनुरोध करने के लिए:

JavaScript

const eventPatch = {
  conferenceData: {
    createRequest: {requestId: "7qxalsvy0e"}
  }
};

gapi.client.calendar.events.patch({
  calendarId: "primary",
  eventId: "7cbh8rpc10lrc0ckih9tafss99",
  resource: eventPatch,
  sendNotifications: true,
  conferenceDataVersion: 1
}).execute(function(event) {
  console.log("Conference created for event: %s", event.htmlLink);
});

हो सकता है कि इस कॉल के लिए अपने-आप मिलने वाले जवाब में अभी पूरी जानकारी शामिल न हो conferenceData; यह pending के स्टेटस कोड से दिखाया जाता है, स्थिति फ़ील्ड में डालें. कॉन्फ़्रेंस की जानकारी होने के बाद, स्टेटस कोड success में बदल जाता है अपने-आप जानकारी भर जाएगी. entryPoints फ़ील्ड में जानकारी होती है कि किस वीडियो और आपके उपयोगकर्ता डायल इन कर सकें, इसके लिए फ़ोन यूआरआई उपलब्ध हैं.

अगर आपको एक ही इवेंट के साथ कई कैलेंडर इवेंट शेड्यूल करने हैं कॉन्फ़्रेंस का विवरण है, तो आप एक इवेंट से पूरे conferenceData को कोई दूसरा.

कॉन्टेंट कॉपी करना कुछ मामलों में फ़ायदेमंद होता है. उदाहरण के लिए, मान लें कि अगर आपको अपने कारोबार के हिसाब से ऐसा आवेदन जिसमें उम्मीदवार के लिए अलग-अलग इवेंट सेट अप किए जाते हों और इंटरव्यू लेने वाले को—आपको इंटरव्यू लेने वाले की पहचान सुरक्षित रखनी है, लेकिन यह सुनिश्चित करना चाहते हैं कि सभी भागीदार एक ही कॉन्फ़्रेंस कॉल में शामिल हों.