KrotovRoman
12/4/2013 - 10:18 AM

api вконтакте получение названия страны документация: http://vk.com/pages?oid=-1&p=places.getCountryById

api вконтакте получение названия страны документация: http://vk.com/pages?oid=-1&p=places.getCountryById

	if (isset($_GET['code'])) {
    $result = false;
    $params = array(
        'client_id' => $client_id, // id приложения
        'client_secret' => $client_secret, // кодовое слово приложения
        'code' => $_GET['code'],
        'redirect_uri' => $redirect_uri
    );

    $token = json_decode(file_get_contents('https://oauth.vk.com/access_token' . '?' . urldecode(http_build_query($params))), true);

    if (isset($token['access_token'])) {
    
	// получаем название страны
		$params = array(
            'cids'         => $userInfo['country'] 
        );
		
		 $cityInfo = json_decode(file_get_contents('https://api.vk.com/method/places.getCountryById' . '?' . urldecode(http_build_query($params))), true);
        if (isset($cityInfo['response'][0]['cid'])) {
            $cityInfo = $cityInfo['response'][0];
            $result_city = true;
        }
    }
    }
    }
    Выводим
    
    echo $cityInfo['name'];