コード例 #1
0
function api_flickr_photos_geo_correctLocation()
{
    $flickr_user = api_utils_flickr_ensure_token_perms($GLOBALS['cfg']['user'], 'write');
    $photo_id = post_int64("photo_id");
    $photo = _api_flickr_photos_geo_get_photo($photo_id);
    $old_woeid = $photo['woeid'];
    $new_woeid = post_int32("woeid");
    if (!$new_woeid) {
        api_output_error(999, "Missing WOE ID");
    }
    if ($old_woeid == $new_woeid) {
        api_output_error(999, "Nothing to correct!");
    }
    # validate WOE ID preemptively?
    $method = "flickr.photos.geo.correctLocation";
    $args = array('photo_id' => $photo['id'], 'woe_id' => $new_woeid, 'auth_token' => $flickr_user['auth_token']);
    $rsp = flickr_api_call($method, $args);
    if (!$rsp['ok']) {
        api_output_error(999, $rsp['error']);
    }
    $update = array('woeid' => $new_woeid);
    $rsp = flickr_photos_update_photo($photo, $update);
    if (!$rsp['ok']) {
        api_output_error(999, $rsp['error']);
    }
    # throw an error if this fails? feels like overkill...
    $correction = array('photo_id' => $photo['id'], 'user_id' => $photo['user_id'], 'old_woeid' => $old_woeid, 'new_woeid' => $new_woeid);
    flickr_photos_geo_corrections_create($correction);
    #
    $place = flickr_places_get_by_woeid($new_woeid);
    $out = array('photo_id' => $photo_id, 'woeid' => $new_woeid, 'place' => $place);
    api_output_ok($out);
}
コード例 #2
0
function api_flickr_favorites_remove()
{
    $flickr_user = api_utils_flickr_ensure_token_perms($GLOBALS['cfg']['user'], 'write');
    $photo_id = post_int64("photo_id");
    if (!$photo_id) {
        api_output_error(999, "Missing photo ID");
    }
    $method = 'flickr.favorites.remove';
    $args = array('photo_id' => $photo_id, 'auth_token' => $flickr_user['auth_token']);
    $rsp = flickr_api_call($method, $args);
    # Just ignore if not in faves already...
    if (!$rsp['ok'] && $rsp['error_code'] != '1') {
        api_output_error(999, $rsp['error']);
    }
    $out = array('photo_id' => $photo_id);
    api_output_ok($out);
}
コード例 #3
0
function users_ensure_valid_user_from_url($method = '')
{
    if (strtolower($method) == 'post') {
        $user_id = post_int64('user_id');
    } else {
        $user_id = get_int64('user_id');
    }
    if (!$user_id) {
        error_404();
    }
    $user = users_get_by_id($user_id);
    if (!$user || $user['deleted']) {
        error_404();
    }
    return $user;
}