matteocontrini Thank you bro! It works! I wanna share the code with everyone:
<?php
$header = array(
"Authorization: Token YOURTOKENHERE",
"Content-Type: application/json"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://yourdomain.com/api/discussions');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
json_encode((array('data' => array(
'type' => "discussions",
'attributes' => array(
'title' => "title",
'content' => "content"))))));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // On dev server only!
$result = curl_exec($ch);
echo $result;
?>
Replace YOURTOKENHERE and yourdomain.com
Get the token from access_tokens MySQL table