Skip to content

Commit

Permalink
start pulling in missing data from flickr.places.getInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisaaronland committed Nov 14, 2011
1 parent ba28851 commit 93344ce
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
6 changes: 6 additions & 0 deletions www/include/lib_flickr_photos_search.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
loadlib("solr_machinetags");
loadlib("solr_dates");
loadlib("flickr_photos_metadata");
loadlib("flickr_places");

#################################################################

Expand Down Expand Up @@ -75,6 +76,11 @@ function flickr_photos_search_index_photo(&$photo){
}
}

if ($place = flickr_places_get_by_woeid($photo['woeid'])){
$doc['timezone'] = $place['timezone'];
$doc['place'] = $place['place_url'];
}

# TO DO: get timezone and places URL and continent
# just call flickr.places.getInfo for $photo['woeid'] ?
}
Expand Down
35 changes: 35 additions & 0 deletions www/include/lib_flickr_places.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

loadlib("flickr_api");

#################################################################

$GLOBALS['flickr_places_cache'] = array();

#################################################################

function flickr_places_get_by_woeid($woeid){

# sudo memcache me...

if (isset($GLOBALS['flickr_places_cache'][$woeid])){
return $GLOBALS['flickr_places_cache'][$woeid];
}

$method = "flickr.places.getInfo";
$args = array('woe_id' => $woeid);

$rsp = flickr_api_call($method, $args);

if (! $rsp['ok']){
return null;
}

$place = $rsp['rsp']['place'];
$GLOBALS['flickr_places_cache'][$woeid] = $place;

return $place;
}

#################################################################
?>

0 comments on commit 93344ce

Please sign in to comment.