Created
April 23, 2021 05:50
-
-
Save mnh48/a707aec600ac74f4e5d50875fcab5d7c to your computer and use it in GitHub Desktop.
to answer this question: https://stackoverflow.com/questions/53935198/in-my-discord-webhook-i-am-getting-the-error-embeds-0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
+ $rank = 34.2; | |
$url = "https://discordapp.com/api/webhooks/xxx"; // Censored for privacy | |
$hookObject = json_encode([ | |
"username" => "Promotion Logs", | |
"avatar_url" => "https://cdn.discordapp.com/icons/472520717515096078/60cc7dd2864c95a749516d1213359b67.png", | |
"tts" => false, | |
"embeds" => [ | |
[ | |
"title" => "Promotion Logs", | |
"type" => "rich", | |
"description" => "", | |
"url" => "http://police.riverside-roleplay.com/promologs.php", | |
"color" => hexdec( "0099ff" ), | |
"fields" => [ | |
[ | |
"name" => "Name", | |
"value" => "dd", | |
"inline" => false | |
], | |
[ | |
"name" => "Rank", | |
"value" => "$rank", | |
"inline" => true | |
], | |
[ | |
"name" => "Their name", | |
"value" => "dd", | |
"inline" => true | |
], | |
[ | |
"name" => "Old rank", | |
"value" => "dd", | |
"inline" => true | |
], | |
[ | |
"name" => "New rank", | |
"value" => "dd", | |
"inline" => true | |
], | |
[ | |
"name" => "Reason", | |
"value" => "dd", | |
"inline" => true | |
], | |
[ | |
"name" => "Date", | |
"value" => "dd", | |
"inline" => true | |
], | |
] | |
] | |
] | |
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); | |
$ch = curl_init(); | |
curl_setopt_array( $ch, [ | |
CURLOPT_URL => $url, | |
CURLOPT_POST => true, | |
CURLOPT_POSTFIELDS => $hookObject, | |
CURLOPT_HTTPHEADER => [ | |
"Length" => strlen( $hookObject ), | |
- "Content-Type" => "application/json" | |
+ "Content-Type: application/json" | |
] | |
]); | |
$response = curl_exec( $ch ); | |
curl_close( $ch ); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$rank = 34.2; | |
$url = "https://discordapp.com/api/webhooks/xxx"; // Censored for privacy | |
$hookObject = json_encode([ | |
"username" => "Promotion Logs", | |
"avatar_url" => "https://cdn.discordapp.com/icons/472520717515096078/60cc7dd2864c95a749516d1213359b67.png", | |
"tts" => false, | |
"embeds" => [ | |
[ | |
"title" => "Promotion Logs", | |
"type" => "rich", | |
"description" => "", | |
"url" => "http://police.riverside-roleplay.com/promologs.php", | |
"color" => hexdec( "0099ff" ), | |
"fields" => [ | |
[ | |
"name" => "Name", | |
"value" => "dd", | |
"inline" => false | |
], | |
[ | |
"name" => "Rank", | |
"value" => "$rank", | |
"inline" => true | |
], | |
[ | |
"name" => "Their name", | |
"value" => "dd", | |
"inline" => true | |
], | |
[ | |
"name" => "Old rank", | |
"value" => "dd", | |
"inline" => true | |
], | |
[ | |
"name" => "New rank", | |
"value" => "dd", | |
"inline" => true | |
], | |
[ | |
"name" => "Reason", | |
"value" => "dd", | |
"inline" => true | |
], | |
[ | |
"name" => "Date", | |
"value" => "dd", | |
"inline" => true | |
], | |
] | |
] | |
] | |
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); | |
$ch = curl_init(); | |
curl_setopt_array( $ch, [ | |
CURLOPT_URL => $url, | |
CURLOPT_POST => true, | |
CURLOPT_POSTFIELDS => $hookObject, | |
CURLOPT_HTTPHEADER => [ | |
"Length" => strlen( $hookObject ), | |
"Content-Type: application/json" | |
] | |
]); | |
$response = curl_exec( $ch ); | |
curl_close( $ch ); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$url = "https://discordapp.com/api/webhooks/xxx"; // Censored for privacy | |
$hookObject = json_encode([ | |
"username" => "Promotion Logs", | |
"avatar_url" => "https://cdn.discordapp.com/icons/472520717515096078/60cc7dd2864c95a749516d1213359b67.png", | |
"tts" => false, | |
"embeds" => [ | |
[ | |
"title" => "Promotion Logs", | |
"type" => "rich", | |
"description" => "", | |
"url" => "http://police.riverside-roleplay.com/promologs.php", | |
"color" => hexdec( "0099ff" ), | |
"fields" => [ | |
[ | |
"name" => "Name", | |
"value" => "dd", | |
"inline" => false | |
], | |
[ | |
"name" => "Rank", | |
"value" => "$rank", | |
"inline" => true | |
], | |
[ | |
"name" => "Their name", | |
"value" => "dd", | |
"inline" => true | |
], | |
[ | |
"name" => "Old rank", | |
"value" => "dd", | |
"inline" => true | |
], | |
[ | |
"name" => "New rank", | |
"value" => "dd", | |
"inline" => true | |
], | |
[ | |
"name" => "Reason", | |
"value" => "dd", | |
"inline" => true | |
], | |
[ | |
"name" => "Date", | |
"value" => "dd", | |
"inline" => true | |
], | |
] | |
] | |
] | |
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); | |
$ch = curl_init(); | |
curl_setopt_array( $ch, [ | |
CURLOPT_URL => $url, | |
CURLOPT_POST => true, | |
CURLOPT_POSTFIELDS => $hookObject, | |
CURLOPT_HTTPHEADER => [ | |
"Length" => strlen( $hookObject ), | |
"Content-Type" => "application/json" | |
] | |
]); | |
$response = curl_exec( $ch ); | |
curl_close( $ch ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment