How to get TV info from Google Calendar Event? - google-calendar-api

I'm using the Google Calendar API to retrieve events for each of my favorite sports teams. An example calendar can be found here.
When you click on an event, it will show you information about the game, including the TV network it'll be played on, like this:
I'm making a home automation script to automatically detect events and turn on my TV etc., and change to the correct channel. My problem is that when I make a call to the API, the response doesn't include the TV information, each item looks like this:
{
"kind": "calendar#event",
"etag": "\"3014707204000000\"",
"id": "20171021T233000_2017102123",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=MjAxNzEwMjFUMjMzMDAwXzIwMTcxMDIxMjMgbmhsXzIzXyU1N2FzaGluZ3RvbislNDNhcGl0YWxzI3Nwb3J0c0B2",
"created": "2017-06-22T20:49:57.000Z",
"updated": "2017-10-07T05:20:02.000Z",
"summary": "Panthers # Capitals",
"creator": {
"email": "nhl_23_%57ashington+%43apitals#sports#group.v.calendar.google.com",
"displayName": "Washington Capitals",
"self": true
},
"organizer": {
"email": "nhl_23_%57ashington+%43apitals#sports#group.v.calendar.google.com",
"displayName": "Washington Capitals",
"self": true
},
"start": {
"dateTime": "2017-10-21T19:30:00-04:00"
},
"end": {
"dateTime": "2017-10-21T22:30:00-04:00"
},
"transparency": "transparent",
"visibility": "public",
"iCalUID": "20171021T233000_2017102123#google.com",
"sequence": 0,
"gadget": {
"iconLink": "https://calendar.google.com/googlecalendar/images/sport_hockey.png"
}
}
Does anyone know where this information is stored or if it's retrievable?
Thanks

maybe you can after getting that json reply download the "htmlLink" and parse the line that says TV:
It would be something like this(pseudo code):
Get JSON
Execute something like curl htmlLinkValue | awk '/TV:/' > result.txt
Read that file that will contain the networks.
Regards

Related

how to get specific items data from google calendar api

hi I am using google api to get all the events which is working fine. There is a parameter where I can specify fields name which I need to retrieve. There is a filed named as items where all the events data are coming. Now I want to get specific data of that items filed. Not all the data.
This is how I am getting all the data of that items.
https://www.googleapis.com/calendar/v3/calendars/CALENDAR_ID/events?showDeleted=true&timeMax=2021-08-16T06%3A00%3A46.000Z&timeMin=2021-04-16T06%3A00%3A46.000Z&prettyPrint=true&fields=items&key=[YOUR_API_KEY]
This is how data are coming.
{
"items": [
{
"kind": "calendar#event",
"etag": "\"hfsfjadj\"",
"id": "adfjadfjad",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=adfjdafjd",
"created": "2021-05-24T05:47:42.000Z",
"updated": "2021-05-24T05:47:42.331Z",
"summary": "dafhafj",
"creator": {
"email": "adfjadfj#gmail.com",
"self": true
},
"organizer": {
"email": "adfjadfj#gmail.com",
"self": true
},
"start": {
"dateTime": "2021-05-24T11:30:00+06:00"
},
"end": {
"dateTime": "2021-05-24T12:30:00+06:00"
},
"iCalUID": "dfjdfjdfj#google.com",
"sequence": 0,
"reminders": {
"useDefault": true
},
"eventType": "default"
}
]
}
I wanted to fetch only id, start,end and summary not the entire thing which is given above.
You can specify nested fields by enclosing them in round brackets, and multiple fields should be separated by commas. Your provided fields would be something like this:
items(id,start,end,summary)
Therefore, the URL would change from this:
https://www.googleapis.com/calendar/v3/calendars/CALENDAR_ID/events?showDeleted=true&timeMax=2021-08-16T06%3A00%3A46.000Z&timeMin=2021-04-16T06%3A00%3A46.000Z&prettyPrint=true&fields=items&key=[YOUR_API_KEY]
To this:
https://www.googleapis.com/calendar/v3/calendars/CALENDAR_ID/events?showDeleted=true&timeMax=2021-08-16T06%3A00%3A46.000Z&timeMin=2021-04-16T06%3A00%3A46.000Z&prettyPrint=true&fields=items(id%2Cstart%2Cend%2Csummary)&key=[YOUR_API_KEY]
Reference:
Partial response

Transfer control with inline buttons in telegram (bots)

If you have a bot-generated in-line button in a chat, that inline button can be used to take you to a bot.
My question is - is the reverse possible?
Can the bot have an inline button (when directly communicating with it) and it can transfer control to a group where the user and bot are both present
Consider this scenario:
I have a bot that track country names. When added to a group it detects a country name and says “see information about the country”.
When you click the button, the bot takes you to a chat with it (changes wondows and moves you out) and then the bot displays information about the country.
The bot then has a “go back or cancel” inline button.
If you click that button, it should take you BACK to the originating group you came from. Is that possible?
Variation:
Can it move you back to the originating group automatically (without an inline button) but say based on some text you type?
All I got is you wanna to take back your users to their refer place right?
For example you have "Back" button in your channel. If user came from Channel A you want to detect that when it clicks on Back button you want to take it back to Channel A.
No it's not possible. Telegram bots can't track user activity like this. But Telegram do itself. For example if you visit some channels like this:
Channel A => First Post => Go to another channel (Channel B) => Then go to admin profile
If you click Back button triple time you will go to first step which in this case is Channel A
Bot if your bot is in one private group or private channel you can get the link of every message because Telegram added this feature here :
you can now copy links to messages in private groups and channels – just like you could with public messages.
So if user mention your bot's username on any message in private group/channel you can get the link of that message. Here is some example :
{
"ok": true,
"result": [{
"update_id": 954197936,
"message": {
"message_id": 188,
"from": {
"id": 223110107,
"is_bot": false,
"first_name": "Ğąme ",
"last_name": "Ǿver!",
"username": "GameO7er",
"language_code": "en"
},
"chat": {
"id": -1001241538300,
"title": "Game Over Test Group",
"type": "supergroup"
},
"date": 1576312634,
"reply_to_message": {
"message_id": 130,
"from": {
"id": 156878147,
"is_bot": false,
"first_name": "Carlos F",
"username": "#Carlos****",
"language_code": "en"
},
"chat": {
"id": -1001241538300,
"title": "Game Over Test Group",
"type": "supergroup"
},
"date": 1554783715,
"text": "Hello Game Over!"
},
"text": "#Go***bot",
"entities": [{
"offset": 0,
"length": 10,
"type": "mention"
}]
}
}]
}
The link of this message is:
https://t.me/c/1241538300/130
As you can see it will be generate from chat id
"chat": {
"id": -1001241538300,
"title": "Game Over Test Group",
"type": "supergroup"
},
remove -100 from -1001241538300 then you have 1241538300 and contact /c/message_id to end of it.
"date": 1576312634,
"reply_to_message": {
"message_id": 130,
"from": {
"id": 156878147,
"is_bot": false,
"first_name": "Carlos F",
"username": "#Carlos****",
"language_code": "en"
},
and you will have :
https://t.me/c/1241538300/130

How to make http post with the value of "Input.Date" from Outlook Adaptive Card?

I could http post only with Input.Number now, but Input.Date and Input.Text both receive 400 error.
I was planning to create a Microsoft Flow to receive some value from Outlook Adaptive Card Action.Http Post method, I followed some articles from internet show me how to do that, finally I get rid of the 401 error because it needs Authorisation header.
Okay, then I moved on to test http payload. The body couldn't be something like "body": "test", otherwise it will either gives me an 400 or even not shows adaptive card in email at all. After I learned that I have to use they officially suggested {{someId.value}} into "body".
I succeeded for the first time with Input.Number:
{
"type": "Input.Number",
"id": "test1",
"title": "New Input.Toggle",
"value": "",
"validation": null,
"placeholder": "Placeholder text",
"min": "0",
"max": "60"
}
Then outlook tells me it is successful and I did get the endpoint flow run and receive correct payload. And this is the "Action.Http" part:
"actions": [
{
"type": "Action.Http",
"title": "Say hello",
"method": "POST",
"url": "myflowhttptriggerurl",
"body": "{{nameInput.value}}",
"headers": [
{ "name": "Authorization", "value": "" }
]
}
]
Below is what get error:
After then, I tried with Input.Text and Input.Date, they all give me 400, below is payload, and don't worry for Action.Http, I change id each time when testing:
{
"type": "Input.Date",
"id": "h",
"title": "New Input.Toggle",
"value": "",
"validation": null
}
Text payload:
{
"type": "Input.Text",
"id": "newTask",
"isRequired": true,
"placeholder": "Enter a new task"
}
OK, first I would install the "Actionable Messages Debugger" into Microsoft Office to make it easier to understand if the contents of your card is correct.
It appears from the card you are doing it correct, what happening on your flow that is receiving the message?
You could always try send through a JSON object, so your body will be
"body": "{\"comment\":\"{{comment.value}}\"}"
Where comment is the id of your Input.Text as such:
{
"id": "comment",
"type": "Input.Text"
"isMultiline": true,
"placeholder": "Comments"
}

Strange error 403: "Calendar usage limits exceeded" when adding event with attendee

I'm trying to test adding an event to my Google Calendar using Google API Explorer page at Google API Explorer - calendar.event.insert
Specifying 'primary' as the calendarId, and enabling 'OAuth 2.0' authorization.
The request body field is as follows:
{
"summary": "Another test",
"start": {
"dateTime": "2017-01-17T11:30:00+02:00"
},
"end": {
"dateTime": "2017-01-17T12:00:00+02:00"
},
"attendees": [
{
"email": "some_mail#some_domain.com"
}
]
}
But when clicking the 'Authorize and Execute' button, I get the following error:
403
- Show headers -
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "quotaExceeded",
"message": "Calendar usage limits exceeded."
}
],
"code": 403,
"message": "Calendar usage limits exceeded."
}
}
If I send the same request but without the 'attendees' part, it works every time.
What am I doing wrong here?
API explorer dumps you into the same quota with everyone else using the api explorer as most of the quotas are project based and its the same project.
You are probably getting it because there are other people testing what you are testing at the same time. There are also limits to what you can test with that. I suspect it wasn't meant to be fully functional.
Also check Calendar usage limits How much have you been testing?
Calendar usage limits exceeded. This is the result of an API call.
(Don't mix this up with the message "Daily quota exceeded," which
points to insufficient API quota.)
Creating too many events
If a user has created more than 10,000 events in his or her calendar
within a short period of time, that user might lose calendar edit
access.
Solution: Send the requests from your own application rather then using api explorer.
What I am sending works fine.
POST https://www.googleapis.com/calendar/v3/calendars/primary/events?sendNotifications=true&key={YOUR_API_KEY}
{
"end": {
"dateTime": "2017-01-17T11:30:00+02:00"
},
"start": {
"dateTime": "2017-01-17T11:30:00+02:00"
},
"attendees": [
{
"email": "ll#xxxx.com"
}
]
}
Response:
200
- Show headers -
{
"kind": "calendar#event",
"etag": "\"2969293763864000\"",
"id": "did1s0f76g79s1ht5aplhieoik",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=ZGlkMXMwZjc2Zzc5czFodDVhcGxoaWVvaWsgbGF1cmx5NzFAbQa",
"created": "2017-01-17T09:54:41.000Z",
"updated": "2017-01-17T09:54:41.932Z",
"creator": {
"email": "xxxx#gmail.com",
"displayName": "Linda Lawton",
"self": true
},
"organizer": {
"email": "xxxxx#gmail.com",
"displayName": "Linda Lawton",
"self": true
},
"start": {
"dateTime": "2017-01-17T10:30:00+01:00"
},
"end": {
"dateTime": "2017-01-17T10:30:00+01:00"
},
"iCalUID": "1s0f76g79s1ht5aplhieoik#google.com",
"sequence": 0,
"attendees": [
{
"email": "ll#xxxxx",
"responseStatus": "needsAction"
}
],
"reminders": {
"useDefault": true
}
}

Google Calendar Events after 7pm are not retrieved until the Next Day using Google Events API

I've updated this because this question makes more sense than the original. I'm still including the test code that I used to show what's happening.
Please see the comments for more up to date information on what I've found.
Executed API to grab events for today (there should be 1):
/calendar/v3/calendars/{calid}/events?calendarId={calid}&singleEvents=true&timeMin=2013-04-24T00:00:00.000Z&timeMax=2013-04-25T00:00:00.000Z
It retrieves nothing. No events are returned.
If I execute the following (ie, the next day):
/calendar/v3/calendars/{calid}/events?calendarId={calid}&singleEvents=true&timeMin=2013-04-25T00:00:00.000Z&timeMax=2013-04-26T00:00:00.000Z
It retrieves the following which is set for the 24th (yet after 7pm), not the 25th:
{
"kind": "calendar#events",
"etag": "\"GZxpEFttRDAOmLHnWRxLHHWPGwk/01XVNYQjwJ5jTmd05uIgK9e6Uhw\"",
"summary": "test calendar",
"description": "test calendar",
"updated": "2013-04-24T13:09:12.000Z",
"timeZone": "America/Chicago",
"items": [
{
"kind": "calendar#event",
"etag": "\"GZxpEFttRDAOmLHnWRxLHHWPGwk/Z2NhbDAwMDAxMzY2MTQ4ODczODI3MDAw\"",
"id": "d1mdj3dasor22f0nm0lbohru7s",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=ZDFtZGozZGFzb3IyMmYwbm0wbGJvaHJ1N3MgYnZzdG9vbHMuY29tX2xidWt1ZmlnczJjMmFycjViODgycDVhYWhvQGc",
"created": "2013-04-16T21:47:53.000Z",
"updated": "2013-04-16T21:47:53.827Z",
"summary": "this should happen 4/24/2013",
"description": "testing event",
"creator": {
"email": "{my email address}",
"displayName": "my name"
},
"organizer": {
"email": "{calid}",
"displayName": "test calendar",
"self": true
},
"start": {
"dateTime": "2013-04-24T21:21:19-05:00"
},
"end": {
"dateTime": "2013-04-24T21:21:19-05:00"
},
"iCalUID": "d1mdj3dasor22f0nm0lbohru7s#google.com",
"sequence": 0,
"extendedProperties": {
"private": {
"evtKey": "key"
}
},
"reminders": {
"useDefault": true
}
}
]
}
It should be retrieving it for the first api call on the 24th, not the 2nd api call on the 25th unless I'm missing something.
Any ideas? Thanks!
a bit late but if you still needs it. I think the event you retrieved d1mdj3dasor22f0nm0lbohru7 seems to be in default timezone of the calendar, which is America/Chicago. That explains why it only showed when you set your query to 25th UTC time

Resources