I recently made a basic PHP script that accesses the SteamAPI to get a players steam avatar URL but I've run into a issue.
I can't seem to find any info on how to send the string back as a reply to the FETCH request other than just forcing it to redirect to the new URL (I need it to not redirect as the game I'm trying to make this for does not support 200 response codes and nor does it support HTTPS which is why I have to use this PHP script)
This is what I have as the script, it's pretty basic https://pastebin.com/r3e23cSh
Question about PHP
-
- New to forums
- Posts: 14
- https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
- Joined: Sat May 03, 2014 9:01 pm
Re: Question about PHP
Can you elaborate on this a bit further? What is it that you're wanting the script to return? Are you just wanting the script to print out the URL for the avatar?
-
- New to forums
- Posts: 14
- Joined: Sat May 03, 2014 9:01 pm
Re: Question about PHP
I want it to reply to the FETCH request with the URL basically, instead of replying with a 200 redirect response code
Re: Question about PHP
If I understand correctly, then you should just need to be returning a string as output from your script. Something like the following would work:
Code: Select all
<?php
$Avatar = 'http://bmtwebsite.site.nfoservers.com/UserAvatar/noavatar.jpg';
if (isset($_GET['steamid']))
{
$SteamAPI = 'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' . $_GET['apikey'] . '&steamids=' . $_GET['steamid'];
$SteamAPI_Returned = file_get_contents($SteamAPI);
$steamAPI = json_decode($SteamAPI_Returned, true);
if (isset($steamAPI['response']['players'][0]['avatar']))
{
$Avatar = $steamAPI['response']['players'][0]['avatar'];
}
echo $Avatar;
}
?>
-
- New to forums
- Posts: 14
- Joined: Sat May 03, 2014 9:01 pm
Re: Question about PHP
That worked, I saw echo but from what I read on it, it just seemed to be like print is where it just outputs a string to the server console. Guess I should of just tried it first to make sure