Closed ghost closed 5 years ago
Yes, I don’t believe that this library will do it, but a call to the JSON API using the url: http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=XXXXXXXXXXXXXXXXXXXXXXX&steamids=76561197960435530 will return json data and the avatar image URLs. To use this just replace ur steam API key where the X’s are and the 76... area with the steam ID. Here is a tutorial on JSON in php: https://www.tutorialrepublic.com/php-tutorial/php-json-parsing.php
Once you have the URL, I don’t believe that the url changes so you could probably store it in a database or just manually put in the url into a image area. Not 100% sure about that though, I haven’t used this in awhile.
Correction, just checked and it does change if they change there avatar photo.
If the aim is to show who the admin is by showing their avatar and username(with a link to their profile) you would need to use an insert to add users to a database on login then query the row id for that user, I have done this myself, but I’m currently at work, so I’ll jump on later with more info on the how unless someone beats me to it :)
Ok, thanks for your answer. I found the solution, if someone want:
$SteamAPIKey = "3503F6426195374A890F3467D028717C";
$stamidtest = "76561198179720810";
$url = file_get_contents("https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=".$SteamAPIKey."&steamids=".$stamidtest);
$content = json_decode($url, true);
$steamavatar = $content['response']['players'][0]['avatarfull'];
?>
<img src="<?=$steamavatar?>">
And how can i check if steamid64 is valid, else echo wrong steamid ? Because if steam id 64 is wrong it say: Notice: Undefined offset: 0, and for my user i only want something like that: 'SteamID 64 isn't valid !'
If it’s incorrect it will return a http error code More on that here: https://partner.steamgames.com/doc/webapi_overview/responses
Yes but how can i make a confition If(steam return error) { echo "wrong steam id"; } else { ... }
And how can i call function json_response in my "script" ? (Sorry i'm starter)
https://github.com/bman46/Steam-Avatar Here's the code for that. I made it so then if the image doesn't exist then it returns the default ? icon for steam.
Make sure to cache them if you are working on a production site as it will make a API request every time the image is loaded so you will quickly run out of API calls.
Tanks a lot !!!!
No problem
Hi, is it prossible to show profile information (ex: logo) with only the steamid ? (Ex: admin user put is steamid on the admin page and on home page, everyone see is logo)