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); }
function api_privatesquare_venues_checkin() { $venue_id = post_str("venue_id"); $status_id = post_int32("status_id"); if (!$venue_id) { api_output_error(999, "Missing venue ID"); } if (!isset($status_id)) { api_output_error(999, "Missing status ID"); } $fsq_user = foursquare_users_get_by_user_id($GLOBALS['cfg']['user']['id']); $checkin = array('user_id' => $GLOBALS['cfg']['user']['id'], 'venue_id' => $venue_id, 'status_id' => $status_id); # where am I? $venue = foursquare_venues_get_by_venue_id($venue_id); if (!$venue) { $rsp = foursquare_venues_archive_venue($venue_id); if ($rsp['ok']) { $venue = $rsp['venue']; } } if ($venue) { $checkin['locality'] = $venue['locality']; $checkin['latitude'] = $venue['latitude']; $checkin['longitude'] = $venue['longitude']; } # check to see if we're checking in to 4sq too if ($broadcast = post_str("broadcast")) { $method = 'checkins/add'; $args = array('oauth_token' => $fsq_user['oauth_token'], 'venueId' => $venue_id, 'broadcast' => $broadcast); $more = array('method' => 'POST'); $rsp = foursquare_api_call($method, $args, $more); if ($rsp['ok']) { $checkin['checkin_id'] = $rsp['rsp']['checkin']['id']; } # on error, then what? } if ($GLOBALS['cfg']['enable_feature_weather_tracking']) { loadlib("weather_google"); $rsp = weather_google_conditions($checkin['latitude'], $checkin['longitude']); if ($rsp['ok']) { $conditions = $rsp['conditions']; $conditions['source'] = $rsp['source']; $checkin['weather'] = json_encode($conditions); } } $rsp = privatesquare_checkins_create($checkin); if (!$rsp['ok']) { api_output_error(999, "Check in failed"); } $out = array('checkin' => $rsp['checkin']); api_output_ok($out); }
<?php include "include/init.php"; login_ensure_loggedin("/account/foursquare/sync/"); $crumb_key = "foursquare_sync"; $GLOBALS['smarty']->assign("crumb_key", $crumb_key); # put this in a library? which one... $sync_states = array(0 => 'do not sync 4sq checkins', 1 => 'only sync recent 4sq checkins', 2 => 'sync all 4sq checkins past and future'); if (post_isset("done") && crumb_check($crumb_key)) { $ok = 1; if (!post_isset("sync")) { $update_error = "missing sync"; $ok = 0; } if ($ok) { $sync = post_int32("sync"); if (!isset($sync_states[$sync])) { $update_error = "invalid sync"; $ok = 0; } } if ($ok) { if ($sync != $GLOBALS['cfg']['user']['sync_foursquare']) { $update = array('sync_foursquare' => $sync); $ok = users_update_user($GLOBALS['cfg']['user'], $update); if ($ok) { $GLOBALS['cfg']['user'] = users_get_by_id($GLOBALS['cfg']['user']['id']); } else { $update_error = "db error"; } }
features_ensure_enabled("api_authenticate_self"); login_ensure_loggedin(); loadlib("api_keys"); loadlib("api_oauth2_access_tokens"); $crumb_key = 'access_token_authenticate_like_magic'; $GLOBALS['smarty']->assign("crumb_key", $crumb_key); $perms_map = api_oauth2_access_tokens_permissions_map(); $GLOBALS['smarty']->assign_by_ref("permissions", $perms_map); $ttl_map = api_oauth2_access_tokens_ttl_map(); $GLOBALS['smarty']->assign_by_ref("ttl_map", $ttl_map); $step = 1; if (post_isset("done") && crumb_check($crumb_key)) { $ok = 1; $title = post_str("title"); $perms = post_str("perms"); $ttl = post_int32("ttl"); $conf = post_str("confirm"); if ($ok && !$title) { $GLOBALS['smarty']->assign("error", "no_title"); $ok = 0; } if ($ok && !api_oauth2_access_tokens_is_valid_permission($perms)) { $GLOBALS['smarty']->assign("error", "bad_perms"); $ok = 0; } # We're not going to worry about descriptions if ($ok) { $GLOBALS['smarty']->assign("title", $title); $GLOBALS['smarty']->assign("perms", $perms); $GLOBALS['smarty']->assign("ttl", $ttl); $step = 2;
$topic_map = flickr_push_subscriptions_topic_map(); $GLOBALS['smarty']->assign_by_ref("topic_map", $topic_map); if ($user_id = get_int32("user_id")) { $owner = users_get_by_id($user_id); if (!$owner) { error_404(); } $GLOBALS['smarty']->assign_by_ref("owner", $owner); } $is_backup_user = $owner && flickr_backups_is_registered_user($owner) ? 1 : 0; $GLOBALS['smarty']->assign("is_backup_user", $is_backup_user); if ($is_backup_user) { $crumb_key = "create_feed"; $GLOBALS['smarty']->assign("crumb_key", $crumb_key); if (post_str("create") && crumb_check($crumb_key)) { $topic_id = post_int32("topic_id"); if (flickr_push_subscriptions_is_valid_topic_id($topic_id)) { # HEY LOOK! THIS STILL DOESN'T DEAL WITH FEEDS THAT # NEED OR HAVE TOPIC ARGS (20120605/straup) # As a practical matter that just means that the # API call to register a subscription with # Flickr will fail. Since we're already # disabling these topics at the template layer I # am less inclined to also check here. If # someone is passing args that means they're # just doofing around and well, you know, # whatever... (20120612/straup) $sub = array('user_id' => $owner['id'], 'topic_id' => $topic_id); $rsp = flickr_push_subscriptions_register_subscription($sub); $GLOBALS['smarty']->assign_by_ref("create_sub", $rsp); }