Good afternoon gentlemen, faced with such a problem. I used to do a user's parser, everything was fine. Now I try to parse the inventory, in the end, after the 3rd reload of the page, the Steam does not respond, and begins to respond only after a minute of waiting. How to be? if the site is used by 10 people, then the inventory will not be parsed at all. If anything, I take the content like this - file_get_contents (' http://steamcommunity.com/profiles/ '. $ Id. '/ Inventory / json / 730/2'); There was a thought to launch a request through TOR, changing the chain with each request, thereby changing the IP address, but this is a crutch.
- So is this not it? Or is there another way to parse the inventory? If yes - you can throw off the link, I will be very grateful - Corle
- I would for the inventory, here I look everywhere using a method like me on stackoverflow.com/questions/39142591/… - Corle
- I have an API Kay, I did authorization through Steam. I just need the inventory - Corle
- Yes, indeed, this endpoint is also positioned as api, sorry =) - vp_arth
|
1 answer
If you read the error code, you yourself would understand everything:
Ignored this time (29)
The system knows that you recently requested exactly this resource and prohibits you from spamming it with identical requests.
You just need to cache the results of all queries.
To get the response body when an error occurs
You need to pass a context with the parameter to file_get_contents :
$context = stream_context_create(array( 'http' => array('ignore_errors' => true), )); $result = file_get_contents($uri, false, $context); $data = json_decode($result, true); if (!empty($data['error'])) { throw new \Exception("SteamAPI Error: {$data['error']}"); } PS:Expires their smartest headline:
Expires: Mon, 26 Jul 1997 05:00:00 GMT
- Wait a second, you probably don’t get an answer body with an error) Now I’ll add the answer. - vp_arth
- And you can more detail about the title. Does it give a date / time type, when can I make a second request? - Corle
- This header should give a date in the future, to which you can safely cache the answer, the browser does it automatically, for example. But in steam, this title is useless, because 1997) - vp_arth
- I think you can cache requests in some redis for a couple of minutes. You can also create answer files from poverty. - vp_arth
|