UPD
<?php
set_time_limit(600);
$ids = array ("", "", "", "", "", ""); //тут id групп/пабликов, из которых нужно сделать репосты
foreach ($ids as $gid2){
$token = '';
$gid = '';
$wall = file_get_contents("https://api.vk.com/method/wall.get?v=5.7&filter=all&owner_id=-".$gid2);
$wall = json_decode($wall);
$wall = $wall->response->items;
$i = mt_rand(1, count($wall));
$x = $wall[$i]->post_type;
$z = $wall[$i]->is_pinned;
if($x == 'post'){
if($z !== 1){
$repost = file_get_contents("https://api.vk.com/method/wall.repost?v=5.7&object=wall-".$gid2."_".$wall[$i]->id."&group_id=".$gid."&access_token=".$token);
$repost = json_decode($repost);
}}
sleep(30);} //указав sleep выполнился только один репост. В чем может быть дело?
?>