As the API Vkontakte to over 5000 friends method friends.get()?

Trying to get friends list from user in PHP, number of friends more than 9 thousand, VK API, the method "friends.get" there are restrictions on the receipt of only 5,000.
Initially tried to this way:
$token = "XXXXXX"; //token
$friends_get = api ('https://api.vk.com/method/friends.get?order=name&fields=name&name_case=ins&v=5.28&access_token='.$token);
$count = $friends_get['count']; // get array of users
for ($i=0; $i < $count; $i++) { 
$banned = $friends_get ['items'][$i]['deactivated'];//Select users with a status of 'deactivated'
$id = $friends_get ['items'][$i]['id']; //get a list of user IDs
if ($banned == banned){ //check if the page is blocked

Then drove the whole thing into an array and cycle through that would select only blocked, not the essence..
The problem arose in the fact that friends are more than 5 thousand and I can't figure out how to get the rest.

Tried such request:
$members = json_decode(file_get_contents("https://api.vk.com/method/friends.get?user_id=436764&offset=9000&fields=name"),true);


Added "offset=" and the like were able to remove another part, but can't figure out how to combine them with the previous five thousands, or the request to perform a few times and all put together.
June 8th 19 at 17:05
2 answers
June 8th 19 at 17:07
Do in a loop. Each time increase the offset by 5000 until it is more returned to the field, count the total number of friends. Don't forget about the limit of 3 request per second.

You can even bother to cram all of the code in execute(), then PHP will be followed by a single request, and the cycle will be scrolled sides VK.
+1 for execute. It works faster and will be counted for 1 request. - vito.Hoeg commented on June 8th 19 at 17:10
Washed down the option to execute:
$friends_get = api('execute?access_token=xxxxxx&code={return {"friends": API.friends.get({"count": 5000, "user_id":433336684, "fields":"name"}), "friends2": API.friends.get({"user_id":433336684, "fields":"name","offset":5000})};');

In the browser the link works with a Bang, when you try to get the data in PHP void(

//Feature request to VK API
 function api($method) {
 $response = curl("https://api.vk.com/method/".$method);
 $json = json_decode($response, true);
 if($json["error"]["error_msg"]) {
 return $json["error"];
 } else {
 return $json["response"];
}
}

//Function to links
 function curl($url) {
 $ch = curl_init($url);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
 curl_setopt($ch, THIS, false);
 curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
 $response = curl_exec($ch);
curl_close($ch);
 return $response;
 }

I can not understand why so - stephany_Stark commented on June 8th 19 at 17:13
maybe the line was too long. Try GET instead of POST method to send the procedure code. - Lorena commented on June 8th 19 at 17:16
June 8th 19 at 17:09
wasimi module vk-io, there is their API over the VC, allows for a couple of lines to collect data streams

Find more questions by tags PHPVKontakte