API、curl、PHP を使用した PUT 実行時に「BAD CSRF」エラーが発生

どうもありがとう!これで解決しました。

同じ問題を抱えている他の人のために:

$url = 'https://www.website.com/{username}.json';
$data = ['name' => 'George'];
$api_key = CUSTOM_DISCOURSE_API;

$headers = array("Content-Type: multipart/form-data;", "Api-Key: $api_key", "Api-Username: system");


$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers );
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));

$result = curl_exec( $ch );

if ( curl_errno( $ch ) !== 0 ) {
   // エラーを処理し、curl_close( $ch ) を呼び出して戻る。
}

curl_close( $ch );

$discourse_user = json_decode( $result );
「いいね!」 4