Php 如何在trello中使用webhook发送操作?

Php 如何在trello中使用webhook发送操作?,php,curl,trello,Php,Curl,Trello,每当在我的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"][

每当在我的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服务器上托管了此文件

另外,当我通过内核独立运行这个脚本时,我可以在我的卡上看到一条新的注释。我认为在服务器上托管文件存在一些问题


我是网络新手,所以详细的解释会很有帮助

默认情况下,json_decode返回对象,如果希望在关联数组中返回输出,则必须将第二个参数作为布尔值“true”传递。 因此,将第2行替换为以下内容:

$data = json_decode($json, true);