function bp_checkins_foursquare_cron_job() { if (!bp_checkins_is_foursquare_ready()) { return false; } $limit = @ini_get('max_execution_time'); set_time_limit(900); ini_set('max_execution_time', 900); $checkins_cron = new Bp_Checkins_Foursquare_Import(); $checkins_cron->wpcron_import(); set_time_limit(intval($limit)); ini_set('max_execution_time', intval($limit)); }
function wpcron_import() { global $wpdb; $user_metas = $wpdb->get_results($wpdb->prepare("SELECT user_id, meta_value as foursquare_token FROM {$wpdb->usermeta} where meta_key= %s", 'foursquare_token')); if (count($user_metas) < 1) { return false; } $import_results = array(); foreach ($user_metas as $meta) { $user_latest = get_user_meta($meta->user_id, 'foursquare_latest_timestamp', true); $user_token = $meta->foursquare_token; $foursquare_url = $this->foursquare_api_url . '?oauth_token=' . $user_token; $foursquare_url .= '&afterTimestamp=' . $user_latest . '&v=20120519'; $import_results[] = Bp_Checkins_Foursquare_Import::save_activity($foursquare_url, $meta->user_id, $user_latest); } Bp_Checkins_Foursquare_Import::log($import_results); }