function countries_from_freebase ()
{
// build query and issue it
$query = array'limit'=>1000, 'type'=>'/location/country', 'name'=>array(), 'iso3166_1_alpha2'=>array());
$results = freebase_query$query);
// extract country names and codes from the results
$return = array();
foreach ($results as $result) {
if (isset$result'iso3166_1_alpha2'][0])) {
$return$result'iso3166_1_alpha2'][0]] = $result'name'][0];
}
}
// sort
asort$return);
return $return
}