Whether such a request to Vkontakte Api?

Here is my code in which I want to list the ID "friends of friends of a particular person" a for Loop can be repeated about 500 times, so the execution of the 500 requests api.vkontakte.ru/method/friends.get runs very long.
I suggested that you can make a request using a stored procedure execute.
For this we need to create an application, go to stored procedure and create a "new procedure", where to register my request to the api.

Question: is it even possible to implement my code in a stored procedure, if I use the dynamic variable $_GET["userid"] ? I can't advance in the procedure to enter the specific numbers.. they are always different, because the variable $_GET["userid"] can contain different values..

What to do?

$resp = file_get_contents('https://api.vkontakte.ru/method/friends.get?user_id='.$_GET["userid"].");
 $data = json_decode($resp, true);
 print count($data[response]);
 for($i=0;$i<count($data[response]);$i++) { $resp2="file_get_contents('https://api.vkontakte.ru/method/friends.get?user_id='.$data[response][$i].");" $data2="json_decode($resp2,", true); $friends .="implode(","," $data2[response]).","; } print $friends;< code></count($data[response]);$i++){>
July 9th 19 at 13:57

Find more questions by tags VKontakte