php - 如何通过 OAuth 登录以便 cron 作业可以运行

标签 php javascript oauth trello

不能 100% 确定我的标题措辞是否正确,但这就是我想要做的。

我写了一个主要是 JS 的小页面和一个小的 PHP 爬虫。该脚本运行,连接到 Trello,根据它发现的内容,它使用 PHP 抓取器抓取另一个站点,然后更新 Trello 中的一些卡片。

作为一个可以在浏览器中加载的页面,这很好,但我想将它设置为一个页面,在我们的服务器上作为 cron 作业运行。我不知道如何修改我的脚本以自动登录到 Trello。我知道我可以运行一次,授权 30 天等,但理想情况下我不想一直这样做。我对此有点陌生,所以欢迎任何关于如何最好地处理它的建议。

**从网络应用移过来

最佳答案

生成一个不会过期的 API token 可能是最简单的方法,而不是尝试模拟登录到 Trello。

首先,在

生成一个应用程序 key

https://trello.com/1/appKey/generate

然后,在

处生成一个不会过期的读/写 token

https://trello.com/1/authorize?key=substitutewithyourapplicationkey&name=My+Application&expiration=never&response_type=token&scope=read,write

这应该足以处理棋盘和卡片 GETPUT,而且您不必担心获得新 token ,因为它不会永远不会过期。

例如,您可以阅读一 block 板子:

获取 https://api.trello.com/1/boards/id_of_board?key=substitutewithyourapplicationkey&token=substitutewithyournonexpiringtoken

或修改卡片

PUT https://api.trello.com/1/cards/id_of_card?desc=New%20Description&key=substitutewithyourapplicationkey&token=substitutewithyournonexpiringtoken

有关详细信息,请参阅 https://trello.com/docshttps://trello.com/api

关于php - 如何通过 OAuth 登录以便 cron 作业可以运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9164966/

相关文章:

javascript - MooTools:如何用文本插入替换现有字段文本?

asp.net - 使用 javascript 进行回发

oauth - Yahoo OAuth 实现无法离线工作

php - 如何在我的 in php 应用程序中修复来自 sqlite 的这些警告?

php - Laravel Spark 重定向注册

php - Paypal Rest API - 提交账单地址

php - Wordpress 用户认证流程

javascript - 自相矛盾的 Javascript 变量定义

android - 我不断收到验证错误 : client_id provided in the request does not match any of the registered clients

javascript - 未知的身份验证策略 "github"