I am trying to create a comment on my card whenever a card is created on my trello board. I have access to my Api key and Token.
$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);
I am able to store the response from webhook in myjson.txt but unable to send a curl POST request to comment on the card which is created. I have hosted this file on a apache2 server which is running.
Also when i am running this script independently through my kernel, i can see a new comment made on my card. I think there is some issue with hosting a file on a server.