【发布时间】:2021-07-02 17:22:40
【问题描述】:
我需要访问一个站点:https://c.xkcd.com/random/comic/ 并使用 JSON API 了解详细信息。
示例 JSON:
{"month": "2", "num": 64, "link": "", "year": "2006", "news": "", "safe_title": "Solar Plexus", "transcript": "[[Hat guy and man standing there talking]]\nHat guy: Asolarplexussayswhat?\nMan: What?\n[[They continue to stand there]]\n[[They continue to stand there]]\n[[Hat guy punches the man in the chest]]\n{{alt: It hurts to be hit there, you know}}", "alt": "It hurts to be hit there, you know", **"img": "https://imgs.xkcd.com/comics/solar_plexus.jpg"**, "title": "Solar Plexus", "day": "15"}
我需要提取图像 (img) 并使用 phpmailer 将其作为附件和内联内容发送。我需要每 5 分钟执行一次,每次使用一个随机 url。
https://c.xkcd.com/random/comic/ 每次访问时都会显示随机漫画。
我曾想过使用 curl 下载图像,但我不知道如何以编程方式每 5 分钟执行一次。
nb:我不能使用任何框架。
【问题讨论】:
-
你有没有尝试过?你到底卡在哪里了?