Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

ruby - Calendar Events Notification not received on server

I'm trying to watch google calendar events.

I have written this code:

  def watch_calendar_event
    result = @client.execute(
      api_method: @calendar_api.events.watch,
      parameters: { calendarId: 'primary' },
      body_object: watch_hash,
      headers: {'Content-Type' => 'application/json'}
    )
    if result.status == 200
      watch_data = result.data
      @calendar.update booking_expiration: watch_data.expiration, booking_id: watch_data.id, booking_resource_id: watch_data.resourceId, booking_resource_uri: watch_data.resourceUri, watching_event: true
    end
  rescue Exception => ex
    raise GoogleCalendarException, ex.message
  end

And I'm getting a 200 success message with other details like booking_id, resource_id and resourceUri.

But when I create a new event on the google calendar I'm not getting any notification on my server.

Any idea what could be the reason.

Also note I have done everything they have asked here and I have also configured an https server for this.

My webhook URL is like: https://dev.application.com/notifications & I have also opened routes for this.

My route:

post '/notifications', to: "calendars#calendar_events_watch", defaults: {format: 'json'}

My controller code:

  def calendar_events_watch
    logger.info "Received an event notification. **************************#{request.env.inspect}"
    if request.env["HTTP_X_GOOG_RESOURCE_STATE"] != "sync"
      channel_id = request.env["HTTP_X_GOOG_CHANNEL_ID"]
      resource_id = request.env["HTTP_X_GOOG_RESOURCE_ID"]
      # resource_uri = request.env["HTTP_X_GOOG_RESOURCE_URI"]
      # channel_token = request.env["HTTP_X_GOOG_CHANNEL_TOKEN"]
    end
    render status: 200
  end
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...