Skip to content

Commit

Permalink
feat: rewrite with curl
Browse files Browse the repository at this point in the history
  • Loading branch information
Rushaway authored Oct 6, 2023
1 parent d17a82f commit 9492e22
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions web/includes/SteamID/VanityURL.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,18 @@ public static function resolve($url, $steamApiKey)
{
$endpoint = "https://api.steampowered.com/ISteamUser/ResolveVanityURL/v1/?key=$steamApiKey&vanityurl=$url";

//TODO: Rewrite with curl
$data = json_decode(file_get_contents($endpoint), true);
$curl = curl_init($endpoint);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);

if (curl_errno($curl)) {
curl_close($curl);
return false;
}

curl_close($curl);
$data = json_decode($response, true);

if ($data['response']['success'] === 1) {
return $data['response']['steamid'];
}
Expand Down

0 comments on commit 9492e22

Please sign in to comment.