Reputation: 23
I'm try to send PATCH request with curl to give for user role.
$curl = curl_init("https://discordapp.com/api/v8/guilds/935503210934833192/members/" . $userid);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
$data2 = array(
"roles" => 935504716505436200,
);
$data2 = json_encode($data2);
$headers2 = ["Authorization: Bot token", "Content-Type: application/json"];
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers2);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data2);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
$role_result = curl_exec($curl);
curl_close($curl);
die(var_dump($role_result));
#header("Location: user.php");
But always get this error string(43) "{"message": "401: Unauthorized", "code": 0}"
, what i'm can do wrong? I'm sure token is correct.
Upvotes: 1
Views: 791
Reputation: 1
So, as I can see you are trying to PATCH a guild member, but you are not calling the right API URL.
/guilds/{guild.id}/members/{user.id} - as you can see, you need to provide the user's ID you want to PATCH.
Upvotes: 0
Reputation: 38
So, as I can see you are trying to PATCH
a guild member, but you are not calling the right API URL.
/guilds/{guild.id}/members/{user.id}
- as you can see, you need to provide the user's ID you want to PATCH
.
Upvotes: 2