Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Set names to lowercase for URL injection.
- $TermLower = strtolower($_GET["Term"]);
- $UserLower = strtolower($_GET["User"]);
- // Inject lowercase names to get correct capitalization of usernames.
- $ch = curl_init("https://api.urbandictionary.com/v0/define?term=" . $TermLower);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $result = curl_exec($ch);
- curl_close($ch);
- // Decode the above JSON data.
- $payload = json_decode($result, true);
- // No Term was entered after the command.
- if (empty($_GET["Term"]))
- {
- echo 'Error: ' . htmlspecialchars($_GET["Term"]) . ' is needed to be specify!';
- die();
- }
- // Print the output.
- echo '(' . htmlspecialchars($_GET["User"]) . ') Definition of ' . $TermLower . ': ' . $payload->definition;
- ?>
- Example: urbandict.php?Term=csgo&User=TwitchUsername
Add Comment
Please, Sign In to add comment