This file contains hidden or 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 | |
// Get the contents of a URL | |
function curl_get_contents($url): string | |
{ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE); | |
curl_setopt($ch, CURLOPT_HEADER, FALSE); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | |
curl_setopt($ch, CURLOPT_URL, $url); |
This file contains hidden or 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
// check if a reddit user exists using response code | |
// returns "TRUE" if they exist | |
// returns Error message if 404 response | |
function checkUser(input) { | |
// check that the input is a string | |
if (typeof user == 'string' && user.length) { | |
// open cache service for caching results | |
var cache = CacheService.getScriptCache(); | |
// remove u/ and trailing spaces from username to normalize inputs | |
var user = input.replace(/^\/?(user|u|U)\//, "").trim(); |
NewerOlder