如何使用PHP通过Google Calendar API添加大量事件通知提醒? [英] How to add large number of event notification reminder via Google Calendar API using PHP?

查看:325
本文介绍了如何使用PHP通过Google Calendar API添加大量事件通知提醒?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在用户的日历中添加一个事件通知,他们都有我的Google Apps帐户。
我的用户数量现在是200,但会增加到1500.
如何通过PHP从Google Calendar API添加所有这些通知?
次要目标是所有拥有移动配置的用户也将收到短信通知。
我的问题是,如果我现在启动一个脚本来向5分钟内启动的事件添加200个通知,则需要很长时间,因此一些用户无法及时收到通知。



在此先感谢!

Alberto

解决方案<简单地说,将大量请求分散到更小的请求集合中。
现在大部分服务器都是多核心的,它应该能够执行多任务处理。

设置两个脚本

主脚本


  1. 获取5分钟内开始的事件

  2. 查找所有用户&需要通知的细节(假设为200)每10次通知

  3. ,产生一个调用Notification脚本的 shell_exec 进程,以及确保将调用推入后台(请参阅 php执行后台进程

通知脚本


  • 接收需要通知的10个用户的详细信息(详细信息从主脚本输入)

  • 处理通知



好处

200 x 1 = 200秒



现在,您只需要

1秒钟为master +(10 x 1秒)= 12秒



请注意



服务器&带宽资源不是无限的,

有一个限制你的服务器可以同时运行多少个进程,

这取决于你执行测试和微调

I've to add one event notification inside of the calendar of my users they all have an account of my Google Apps. The number of my users are for now 200 but it will increase to 1500. How can I add via PHP from Google Calendar API all those notifications? The secondary objective is that all the users that has the mobile configuration will also receive the sms notification. My issue is that if I launch a script now to add 200 notifications to an event that starts in 5 minutes, it will take a lot of time, so some users do not receive in time the notification.

thanks in advance!

Alberto

解决方案

In nutshell, spread the large set of requests into smaller set of request.
Most of the servers nowadays are multi core, it should capable to perform multitasking

Setup two scripts

Master scripts

  1. fetch the event that start in 5 minutes
  2. find all the users & details that need to be notified (assume is 200)
  3. for every 10 notifcations, spawn a shell_exec process that calling Notification script, and make sure push the calling into background (refer php execute a background process )

Notification script

  • receive the details of 10 users need to be notified (details input from master scripts)
  • process the notification

Benefits

So, instead of traditional fetch one user notify one user,
you need 200 x 1 = 200 seconds

Now, you just need

1 seconds for master + (10 x 1 seconds) = 12 seconds

Things to take note

Server & bandwidth resources is not unlimited,
there is an capped on how many processes your server can run concurrently,
this up to you to perform testing and fine-tune

这篇关于如何使用PHP通过Google Calendar API添加大量事件通知提醒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆