【发布时间】:2020-05-01 23:33:15
【问题描述】:
每当在我的 trello 板上创建卡片时,我都会尝试在我的卡片上创建评论。我可以访问我的 Api 密钥和令牌。
$json = file_get_contents("php://input");
$data = json_decode($json,true);
$fp = fopen("myjson.txt",'w');
fwrite($fp,$json);
fclose($fp);
$id = (string) $data["action"]["data"]["card"]["id"];
$actionThatTriggered = (string) $data["action"]["type"];
if($actionThatTriggered == "createCard"){
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"https://api.trello.com/1/cards/".$id."/actions/comments?text=hello+world&key=".$apikey."&token=".$tokennumber);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_HEADER,false);
$server_response = curl_exec($ch);
curl_close($ch);
}
我可以将来自 webhook 的响应存储在 myjson.txt 中,但无法发送 curl POST 请求来评论创建的卡片。我已将此文件托管在正在运行的 apache2 服务器上。
另外,当我通过我的内核独立运行这个脚本时,我可以在我的卡上看到一条新的评论。我认为在服务器上托管文件存在一些问题。
我是网络新手,所以详细的解释会很有帮助。
【问题讨论】: