It seems that cURL PHP too slowly for getting data (if to be exact for getting avatars). How I can make it faster?
Now I have some of this:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=".$this->api."&steamids=".$steamid64); // API and SteamID vars
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
$content = json_decode($output, true);
$avatar = $content['response']['players'][0]['avatarfull'];
Work at valve and improve the endpoint to make it faster.
Other than that, nothing you can do besides batching the requests and fetching for multiple steamids at once
Well, some ways to get steam avatar without stopping processes in php engine? I tried JS fetch, but I can't do this without errors :|
At root, your issue is that you aren't caching.
If you're requesting this data from the Steam API every single time a user loads a page with an avatar, you're never going to do it in a performant way.
You need to set up a system that stores the results of those API requests, and only fetches new data when the user logs in again, or enough time has passed, etc.
Well I cached it before but it make it faster with some tricks and it's okay. Thx.
Something else you could try is having the img's src point to a PHP script you wrote that downloads and returns the avatar image for the specified steamid.
You could have the script cache, too, and if your website is behind Cloudflare, you can have Cloudflare cache the images as well.
Sorry, you need to Log In to post a reply to this thread.