コード例 #1
0
<?php

$root = dirname(dirname(__FILE__));
ini_set("include_path", "{$root}/www:{$root}/www/include");
set_time_limit(0);
#
include "include/init.php";
loadlib("backfill");
loadlib("flickr_photos");
loadlib("flickr_photos_search");
if (!$GLOBALS['cfg']['enable_feature_solr']) {
    echo "search indexing is disabled, exiting";
    exit;
}
function index_photo($row, $more = array())
{
    $photo = flickr_photos_get_by_id($row['id']);
    $rsp = flickr_photos_search_index_photo($photo);
}
$sql = "SELECT * FROM FlickrPhotos";
backfill_db_users($sql, 'index_photo');
exit;
        return;
    }
    $method = 'flickr.people.getInfo';
    $args = array('user_id' => $flickr_user['nsid']);
    $ret = flickr_api_call($method, $args);
    if (!$ret['ok']) {
        dumper($args);
        dumper($ret);
        return;
    }
    $rsp = $ret['rsp']['person'];
    $path_alias = $rsp['path_alias'];
    $username = $rsp['username']['_content'];
    echo "[{$user['id']}] path alias: {$path_alias} screen name: {$username}\n";
    if ($path_alias != $flickr_user['path_alias']) {
        $update = array('path_alias' => $path_alias);
        $rsp = flickr_users_update_user($flickr_user, $update);
        echo "[{$user['id']}] update path alias: {$rsp['ok']}\n";
        # just let this fail silently if there's a duplicate
        flickr_users_path_aliases_create($user, $path_alias);
    }
    if ($username != $user['username']) {
        $update = array('username' => $username);
        $rsp = users_update_user($user, $update);
        echo "[{$user['id']}] update username: {$rsp['ok']}\n";
    }
}
# TO DO: a flag/option to only fetch users w/out a path_alias
$sql = "SELECT * FROM FlickrUsers";
backfill_db_users($sql, '_get_nsid');
exit;
コード例 #3
0
<?php

$root = dirname(dirname(__FILE__));
ini_set("include_path", "{$root}/www:{$root}/www/include");
set_time_limit(0);
#
include "include/init.php";
loadlib("backfill");
loadlib("flickr_users_path_aliases");
function set_path_alias($flickr_user, $more = array())
{
    if ($flickr_user['path_alias'] == '') {
        return;
    }
    $user = users_get_by_id($flickr_user['user_id']);
    flickr_users_path_aliases_create($user, $flickr_user['path_alias']);
}
$sql = "SELECT * FROM FlickrUsers";
backfill_db_users($sql, 'set_path_alias');
exit;
コード例 #4
0
<?php

$root = dirname(dirname(__FILE__));
ini_set("include_path", "{$root}/www:{$root}/www/include");
set_time_limit(0);
#
include "include/init.php";
loadlib("backfill");
loadlib("flickr_photos");
loadlib("flickr_photos_exif");
function check_photo($row, $more = array())
{
    $photo = flickr_photos_get_by_id($row['id']);
    $more = array('force' => 1);
    $hasexif = flickr_photos_exif_has_exif($photo, $more);
    # echo "photo {$photo['id']} has exif: {$hasexif}\n";
    if ($hasexif) {
        $update = array('hasexif' => 1);
        $rsp = flickr_photos_update_photo($photo, $update);
        if (!$rsp['ok']) {
            echo "ack! failed to update {$photo['id']}: {$rsp['error']}\n";
        }
    }
}
$sql = "SELECT * FROM FlickrPhotos";
backfill_db_users($sql, 'check_photo');
exit;
コード例 #5
0
            }
            $checkin = array('user_id' => $user['id'], 'checkin_id' => $fsq_checkin['id'], 'venue_id' => $fsq_checkin['venue']['id'], 'created' => $fsq_checkin['createdAt'], 'status_id' => $status_map['i am here'], 'latitude' => $fsq_checkin['location']['lat'], 'longitude' => $fsq_checkin['location']['lng']);
            $venue = foursquare_venues_get_by_venue_id($checkin['venue_id']);
            if (!$venue) {
                $rsp = foursquare_venues_archive_venue($checkin['venue_id']);
                if (!$rsp['ok']) {
                    echo "failed to archive venue '{$checkin['venue_id']}' : {$rsp['error']}\n";
                    echo "skipping...\n";
                    continue;
                }
                $venue = $rsp['venue'];
            }
            if ($venue) {
                $checkin['locality'] = $venue['locality'];
                $checkin['latitude'] = $venue['latitude'];
                $checkin['longitude'] = $venue['longitude'];
            }
            $rsp = privatesquare_checkins_create($checkin);
            if (!$rsp['ok']) {
                echo "failed to archive checkin: {$rsp['error']}\n";
                continue;
            }
            echo "archived 4sq checkin {$checkin['checkin_id']} with privatesquare ID: {$rsp['checkin']['id']}\n";
        }
        # do stuff here...
        $offset += $limit;
    }
}
$sql = "SELECT * FROM FoursquareUsers";
backfill_db_users($sql, "sync_user");
exit;
$root = dirname(dirname(__FILE__));
ini_set("include_path", "{$root}/www:{$root}/www/include");
set_time_limit(0);
include "include/init.php";
loadlib("backfill");
loadlib("foursquare_venues");
function _set_latlon($row, $more = array())
{
    $user = users_get_by_id($row['user_id']);
    $venue_id = $row['venue_id'];
    $venue = foursquare_venues_get_by_venue_id($venue_id);
    if (!$venue) {
        $venue = foursquare_venues_archive_venue($venue_id);
    }
    if (!$venue) {
        echo "can not sort out venue data for '{$venue_id}'\n";
        return;
    }
    $lat = $venue['latitude'];
    $lon = $venue['longitude'];
    $update = array('latitude' => AddSlashes($lat), 'longitude' => AddSlashes($lon));
    $enc_id = $row['id'];
    $where = "id='{$enc_id}'";
    $cluster_id = $user['cluster_id'];
    $rsp = db_update_users($cluster_id, 'PrivatesquareCheckins', $update, $where);
    echo "{$venue_id} : {$lat}, {$lon} {$where}: {$rsp['ok']}\n";
}
$sql = "SELECT * FROM PrivatesquareCheckins";
backfill_db_users($sql, "_set_latlon");
exit;