set_time_limit( 0 );
mb_internal_encoding( 'UTF-8' );
function curl( $url ) {
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
$response = curl_exec( $ch );
curl_close( $ch );
return $response;
}
$countries = json_decode( curl( 'https://api.vk.com/method/database.getCountries?need_all=1&count=1000&offset=0' ) );
$real_id_c = array();
foreach( $countries->response as $country ) {
$real_id_c[] = array( 'vk_id' => $country->cid, 'id' => country( $country->title )[ 0 ]->ID );
}
$limit = 200000;
foreach( $real_id_c as $ids ) {
for( $o = 0; $o <= $limit; $o += 1000 ) {
$cities = json_decode( curl( 'https://api.vk.com/method/database.getCities?country_id=' . $ids[ 'vk_id' ] . '&count=1000&need_all=1&offset=' . $o ) );
if ( empty( $cities->response ) ) {
break;
}
foreach( ( array ) $cities->response as $city ) {
$region = $city->region;
if ( empty( $city->region ) )
$region = '';
print_r( $city );
}
}
}