I am currently developing a web API where I need to listen for Google Calendar updates. I have therefor implemented the google push notifications for PHP following the documentation and everything works fine (Receiving notifications).
The problem I have is that I would like to update the channel expiration time so I don't have to create a new one every time. That is a waste of GPU and API requests, because as the documentation indicates, every time you create a new channel you start with a full initial sync (Synchronize Resources Efficiently) .
Instead, I would like to always make incremental synchronization. Any ideas on how to update the "expiration" field ?
Answer:
You cannot update the channel expiration time, you have to create a new one.
Reference:
From the link you provided, Renewing notification channels:
Currently there is no automatic way to renew a notification channel. When a channel is close to its expiration, you must create a new one by calling the watch method.
Related:
Provide a mechanism to renew activities.watch instead of erroring on non-unique channels
Related
I am integrating the Twitch user account API into my platform and had a look through the API to see if there was a callback section of some sort to send an update to my server when a user starts streaming, but I can't seem to find any reference for one.
Is there currently any services that offer this sort of thing? If not, what would be the best way of running regular checks on all of my users in my Database to see when they are streaming, of course doing this alone would kill the server with database queries, so I'm stuck as to where to go now.
What I am looking to do is receive a callback and then create a post in a social feed that the user has started streaming.
Based on the discussions at the links below, the API doesn't support webhooks and won't anytime soon. Instead, they expect you to use polling. Basically you would set up a worker process that makes requests periodically, such as every five minutes, then creates appropriate social feed posts, etc. You can batch them together if you have a bunch of channels to check (exaple from from the github issue):
https://api.twitch.tv/kraken/streams?channel=riotgames,dota2ti,machinima,esltv_hearthstone
https://github.com/justintv/Twitch-API/issues/211
https://discuss.dev.twitch.tv/t/notifications-using-twitch-api-and-php/1009
I have an application running on LAMP stack.In USER model
after expiration of subscription deadline,I need to set user's current
subscription to default or free subscription.
So I need a background process which always checks for the expiration of user's subscription deadline and set to default subscription.
Is there any other efficient and manageable solution to run a background process which will update user's data ?
Application Environment:
CakePHP,Redis,MariaDB
Please edit if this question isn't good enough to describe my problem :(
So in general your question about recurring event,
if this event do changes in DB and also another actions like send emails or stop some services or connect to remote resource,, you have to use cron job
but if this event only related to DB then you can create recurring event like the following link
In case of PHP there is not so many out-of-the-box solutions. One of the available is rabbitmq-delayed-sample. It is built on top of rabbitmq messaging system.
Usage example:
$container->get('delayed_producer')->delayedPublish(5000, $messageBody, '');
where 5000 is an expiration period after that job will be executed. You can put such code to the new user creation place.
I'm using a Google Calendar Push Notifications in my web app. Currently, I'm able to create a notification channel with a unique id and resource id. I'm also receiving a push notification whenever any event added/edited in the calendar.
What would be the best approach for renewing/recreating channel just before expiry time with users presence? In the Database, I'm saving user id , channel id, expiry time, current channel creation time.
The Google Push Notifications API says that you can renew before the expiration; indeed, they implicitly recommend doing so:
"Currently there is no automatic way to renew a notification channel. When a channel is close to its expiration, you must create a new one by calling the watch method. As always, you must use a unique value for the id property of the new channel. Note that there is likely to be an "overlap" period of time when the two notification channels for the same resource are active."
Does PHP offer no timer mechanism? In Java, I'd note the expiration time and set a Timer or similar to renew the notification just before hand - no need to poll the DB repeatedly for an expiration date that's not going to change...
There is SO MUCH information about google APIs. So I'm getting lost in all the research.
My goal:
I have a spreadsheet under my google docs account. I want to run a cron job every day, pull cell values from a specific cell (it increases to the next row each day) and then do some other API calls to other services, then write the results in another column in that same row.
Most of the oAuth 2.0 stuff needs to ask the user, which can't happen in a cron job. I found something about a service account, but thats a whole new type of account, and it seems to have it's own credentials. I already have 4 types of security credentials created.
Question) How do I authenticate my google account in PHP without asking anything to the user?
The URL I want to use with cURL after authentication is this
https://spreadsheets.google.com/tq?tqx=out:json&tq=<QUERY>&key=<MY KEY>
Thanks to anyone who can help!
I am creating a php website that uses the Google Calendar API. It's working fine with Create, Update and Delete: any event from the PHP website goes into my Google Calendar events after login.
Events created on my site are created in Google Calendar.
What I want now that is: when I create an event from my test page it goes into Google Calendar after login, then if I update or delete that event from Google Calendar then it should automatically update or delete the php website event.
Basically: 1-way sync is working fine but now I want 2-way synchronization.
If anybody has any ideas then kindly share with me, it will be much appreciated.
There are no application hooks in Google Calendar (gCal) that allow you to trigger an action when an event is deleted. Instead you must either poll gCal at intervals (this could be a cron job every few minutes/hours) and update your calendar accordingly, or any time you perform an action from your calendar have a 1 in X possibly of a full re-sync.
This implies that you are using the gCal as the definitive source, and mirroring those changes back to your local application.
well, after following these answers and building a hole 2 way sync process,
i realized there's a push notifications for calendar since 2013.
you will still need a full sync process because the push notification only notifies about a change but no data about the change.
hope it will save you some time.
Push Notifications
Would it not be an option for your system to generate an iCal output at a special, user-specific URL, and then have the user subscribe to that calendar in Google Calendars (or their iCal-reading calendar of choice)?
That way, your system would always hold the authorative calendar, and Google Calendar would reflect any changes you make automatically.
Alternately, if you are wanting changes in the Google Calendar to be reflected in your application, then you may be able to subscribe to iCals for the User's Calendar, and then poll them at a regular interval to reflect any changes the User has made at that end.
I would lean towards the first option (your iCal subscribed through Google Calendar), as it is a simpler and easier solution.