//Запрос к VK, токен уже есть в переменной $tok $wall = file_get_contents("https://api.vk.com/method/users.get?user_ids=".implode(',', $users)."&v=5.40&access_token=$tok"); $wall = json_decode($wall); $result = $wall->response; print_r($result); 

I have such a request, but I heard that it is bad. Tell me why it is bad, and if you can. write a normal query.

  • Nothing wrong with that. Request as request. - ModaL
  • If I press f5 many times, the request does not work) And then in the script I have a bad error because of this request. And sometimes by itself, the request returns void from the first time. Then the script continues to be executed with emptiness, but must be processed. There are not many of them in $ users, 10 - 30 pieces, no more. In general, it goes like this: I take 20 uidvk for example from the base, run it in the request, receive the array, then cut out of the array banned in VK. and then I work with those users who stayed, with those who are not banned. - PHPcoder
  • Well, so naturally, the VKontakte API sets its own restrictions on requests. - ModaL
  • one
    Restriction on the frequency of requests. To track down the error, replace $wall = json_decode($wall); on $wall = json_decode($wall); print_r($wall); $wall = json_decode($wall); print_r($wall); - ModaL
  • one
    Yes, if there is an error, then fulfill your conditions. The request is not vulnerable in any way, because this is the standard and the only api-method of VK. So that the restrictions so often do not concern you, for example, you can get access_token from a mobile application, there the frequency of requests is completely different, or you can access_token different access_token from different accounts randomly. Check the very bottom with the frequency of requests to the API - vk.com/dev/api_requests - ModaL

1 answer 1

Request standards It is necessary to look in the context of the application. If they can often refresh the page, it’s worth caching the request so as not to bomb the VC too often.

If you need to perform many requests in a row, you can memorize the execution time of the last three, and check before the next request whether 1000 milliseconds have passed since the oldest of them. If not, sleep a bit: usleep() .

  • That's just enough for 333 milliseconds, including the limitations on 3 requests per second - gil9red
  • If it is a little requests. When efficiency is important on hundreds of requests, it is better not to be lazy and count the time of the last three. - Sergiks