Hello @pfaffman
Thank you for your help. I tried according to example but there is a error :
401 Authorization Required
My script :
$apikey = "xxxxxxxxxxxxxxxxxxxx";
$username = "xxxxxxxxxxxxxxxxx";
$title = "test";
$raw = "message";
$category = 9;
$url = 'https://myDiscourse.com/posts.json';
$post_fields = array(
'title' => $title,
'raw' => $raw,
'category' => $category,
);
$headers = array("Content-Type: multipart/form-data;","Api-Key: $apikey","Api-Username: $username",);
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query( $post_fields ) );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec( $ch );
if ( curl_errno( $ch ) !== 0 ) {
echo 'Error:' . curl_error($ch);
}
curl_close( $ch );
I made a mistake certainly but I don’t know what. Can you help me please?
Thanks