I'm trying to create a plugin, that sends some custom field data to a node server, when a new page of a certain category is created. Somehow the request doesn't go out. For debugging purposes I removed the if clause to check for the category. Any ideas what could be wrong here?
Code: Select all
<?php
class pluginEvents extends Plugin{
public function afterPageCreate($key){
$page = new Page($key);
$url = "localhost:4000/event-create";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$headers = array(
"Accept: application/json",
"Content-Type: application/json",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
$data = array("message"=>"Test MEssage");
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$resp = curl_exec($curl);
curl_close($curl);
var_dump($resp);
}
}
?>