I want to use the Discord API for my web app written in PHP. I have an OAuth2 token and a bot token from Discord and I want to add a member to a guild with the API. Currently I'm getting the following error:
object(stdClass)#24 (1) { ["access_token"]=> array(1) { [0]=> string(22) "This field is required" } }
My code:
curl_setopt_array($request, [
CURLOPT_URL => "https://discordapp.com/api/guilds/[id]/members/" . $user->id,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => [
"access_token" => $access_token, // oauth2 access token
],
CURLOPT_HTTPHEADER => [
"Authorization: Bot [token]", //bot token
"Content-Type: application/json",
],
CURLOPT_RETURNTRANSFER => true,
]);
I don't understand the error This field is required
, since I send all the required fields. Am I missing something?