Mac 服务器 - 从 PHP 调用 applescript/automator

发布于 2024-10-30 13:37:13 字数 254 浏览 4 评论 0 原文

我有一台 Mac 服务器,用于托管我的网站。 我使用 PHP 创建了一个网页,主要用于创建约会。该页面允许用户选择约会的日期和时间,然后单击提交按钮将其发布到服务器。 我能够在服务器端接收选定的值。

现在我想编写苹果脚本或创建自动操作,这将根据通过 PHP 页面接收的数据在我的 iCal 中创建一个条目。

如何使用我在 PHP 页面中收到的详细信息在我的 mac 服务中创建约会? 我是否以正确的方式思考使用苹果脚本或自动化程序将预约添加到我的 ical 中?

I've a Mac server which I'm using to host my website.
I created a web page using PHP which is basically used to create appointments. The page allows user to select date and time of appointment and clicks submit button to post it to server.
I'm able to receive the selected values on server end.

Now I want to write apple script or create automator action which will create an entry in my iCal from the data received through PHP page.

How can I create appointments in my mac serve ical with the details I'm receiving in PHP page?
Am I thinking in the right way to user apple script or automator to add appointment to my ical?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

愁以何悠 2024-11-06 13:37:13

您可以使用以下命令运行 applescripts

shellexec("osascript /path/to/script.scpt arguments");

比从返回的变量中获取输出。

You can run applescripts with

shellexec("osascript /path/to/script.scpt arguments");

Than grab it output from returned variable.

时光与爱终年不遇 2024-11-06 13:37:13

我不知道 applescript 是如何工作的,但是如果您只想发出命令行命令,您可以使用 系统()

I've no idea how applescript works, but if you just want to issue a command-line command you can use system()

内心旳酸楚 2024-11-06 13:37:13

解决此问题的另一种方法是,不要从 PHP 调用 AppleScript 并尝试围绕可能导致失败的所有边缘情况进行编程(用户在服务器上执行其他操作、没有用户登录、AppleScript 运行时间太长)等),就是让服务器将每个约会的 iCal 文件写入特定目录。然后定期(例如每 5 分钟)运行一个 iCal/Automator 操作,该操作从所述目录导入新的预约 iCal 文件,并在导入到 iCal 后将其删除。

就从 PHP 创建 iCal 文件而言,似乎有许多库提供此功能,包括: BenuuqCaliCalcreator, iCal Maker,或许还有更多。其中任何一个都应该允许您生成与 iCal 兼容且易于导入的 .ics.ical 文件。 iCal 文件肯定比尝试传递各种数据(例如姓名、日期和时间)更具可移植性。时间、地点等,围绕 AppleScript。

而且,为了定期运行 AppleScript/Automator 操作,您可以使用优秀的 Lingon 应用程序,尽管它是 App现在只存储。人们也可以手动编写 launchd .plist 文件(请参阅 man launchd.plist)。

Another way to attack this problem is, instead of calling an AppleScript from PHP and trying to program around all the edge cases which might cause it to fail (user doing something else on the server, no user logged in, AppleScript taking too long to run, etc.), would be to have the server just write out an iCal file for each appointment to a specific directory. Then have an iCal/Automator action which is run periodically (e.g. every 5 minutes) which imports the new appointment iCal file from said directory and deletes it once it's been imported into iCal.

As far as creating iCal files from PHP goes, there seem to be many libraries out there that offer this functionality, including: Benuu, qCal, iCalcreator, iCal Maker, and probably more. Any one of these should allow you to generate an .ics or .ical file that is compatible with iCal and easily imported. An iCal file is certainly more portable than trying to pass various bits of data like name, date & time, location, etc., around to an AppleScript.

And, for running the AppleScript/Automator action periodically, you can use the excellent Lingon application, although it's App Store only now. One can manually write the launchd .plist files as well (see man launchd.plist).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文