Archive for the ‘Uncategorized’ Category

Migrating to https

Google Maps, Geocaching, and WordPress all prefer HTTPS as default now, Google Maps has even begun reducing functionality in their API unless HTTPS is used by the consuming web site.  Therefore we’ve begun migrating the entire BCaching web site over to HTTPS as well.

The mobile apps are still using the BCaching API via HTTP, so that will remain available, but all browser-based use of the web site will be switched over.

We are using LetsEncrypt for our 100% free auto-renewing SSL certificate. See https://letsencrypt.org/ for more details.

We are currently testing functionality at https://test.bcaching.com. Feel free to use that if you’d like and let us know if you encounter any trouble.

Alternate fix for IIS6 eurl.axd 404 error

With ASPNET 4.0 there is a breaking change when using IIS6 with a website that has “legacy” ASPNET 2.0 mixed with ASPNET 4.0 applications.

Extensionless URLs that used to be sent to your configured “default content page” such as “Default.aspx” will instead be sent to eurl.axd followed by a hash code. Unfortunately your ASPNET 2.0 application will not automatically handle that.

Microsoft provides 3 workarounds in its ASPNET V4 Breaking Changes document. Two of them are to not mix ASPNET 2.0 and 4.0 applications in the same web site. The third is to disable extensionless URLs altogether.

But what if you DO want to mix ASPNET 2.0 and 4.0 applications in the same website AND use extensionless URLs in your 4.0 application?

Why not just handle the eurl.axd path and redirect it to your default document? This worked for me:

1. Create a class library (i.e. eurlredirect.dll) with a single IHttpHandler class.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace eurlredirect
{
    public class RedirectHandler : IHttpHandler
    {
        public bool IsReusable
        {
            get { return true; }
        }

        public void ProcessRequest(HttpContext context)
        {
            context.Response.Redirect("Default.aspx");
        }
    }
}

2. Add the class library to your ASPNET 2.0 bin directory.

3. Configure the handler in the ASPNET 2.0 application’s web.config file by adding the following entry to the <httpHandlers> section:

<add verb=”*” path=”eurl.axd” validate=”false” type=”eurlredirect.RedirectHandler, eurlredirect”/>

 

BCaching Field Notes API

The bcaching API is intended for use by mobile geocaching apps to retrieve geocache data and have access to a large repository of geocache data without needing to store it all on the device itself.

The Query API can be found here.

The Notes API is new and has had limited testing. The URL is http://(www|test).bcaching.com/…). It allows a mobile app to upload field notes (finds, dnfs, and notes). When used in combination with the BCaching Query API it can be used to prevent found caches from being re-downloaded in subsequent BCaching queries. Field notes uploaded to BCaching can also be downloaded from BCaching for use in uploading to geocaching.com.

Request format is an HTTP POST or PUT to the following URL (format is nearly identical to the query api):
http://(www|test).bcaching.com/api/notes.ashx?u=<username>&a=add&time=<current-time>&sig=<signature>
where:

  • username is a valid bcaching.com username (UrlEncoded)
  • current-time is the current mobile device time in “java” milliseconds (i.e. java.util.Date.getTime)
  • signature is an md5 hash of the querystring plus an md5 hash of the bcaching user’s password.

The posted request content format is identical to the geocaching fieldnotes text file format. A utf-8 text file, with comma-separated values including waypoint, time, log-type, and text. Multiple notes can be posted when separated by newlines.

<waypoint>,<time>,<log-type>,”<text>”

where:

  • <waypoint> is the geocaching GC#
  • <time> is the complete log date and time in UTC format. For example, 2009-11-25T22:37:55Z. The time may also be expressed in local time with a time zone offset instead of the letter Z.
  • <log-type> is a valid field note log type:
    • Found it
    • Didn’t find it
    • Write note
    • Attended
    • Webcam Photo Taken
    • Private note (bcaching note only, won’t be exported)
  • <text> is the log text. Note that it is surrounded by double-quotes. It can also contain newlines inside the double-quotes and those newlines will not be treated as an end-of-record character but part of the note text.

BCaching API

This topic is no longer up to date. The latest API documentation can be found here on the forums.

The bcaching API is intended for use by mobile geocaching apps to retrieve geocache data and have access to a large repository of geocache data without needing to store it all on the device itself. Response data for all requests except for “login” is in the standard GPX format. All query results are restricted to those that are accessible by the authenticated user.

Request format is
http://(www|test).bcaching.com/api/q.ashx?u=<username>&REQUEST&time=<current-time>&sig=<signature>
where:

  • username is a valid bcaching.com username
  • current-time is the current mobile device time in “java” milliseconds (i.e. java.util.Date.getTime) or equivalent
  • signature is an md5 hash of the querystring plus an md5 hash of the bcaching user’s password.

{{REQUEST}} can be one of the following:

  • Verify login only: a=login
    Does nothing more than return success or failure based on the validation of the username password/hashword.
  • Find nearest caches (Summary): a=find&lat=<latitude>&lon=<longitude>&find=<find>&maxdistance=<max-distance>&maxcount=<max-count>
    Returns summary-only gpx data — with no short or long descriptions, extra waypoints, logs, etc.

     

    • latitude is the latitude in signed degree decimal form i.e. 40.123456
    • longitude is the longitude in signed degree decimal form i.e. -74.987654
    • find is a URL-encoded string to search for caches by waypoint# (with or without the GC prefix) or partial name match.
    • max-distance is optional and specifies the maximum distance in degrees. Default is 0.3 – about 30 miles
    • max-count is optional and specifies the maximum number of nearest caches to return in the gpx data. Default is 50.
  • Get cache detail: a=detail&ids=<cache-id-list>&desc=<description-mode>&wpts=<wpts>&logs=<logs>&tbs=<tbs>
    Returns detailed gpx data for one or more caches

     

    • cache-id-list is a comma-separated list of cache ids (not waypoint numbers). Cache ids are included in the summary gpx request.
    • description-mode indicates what form to send the description and can be one of the following:
      • none: neither short nor long description is included
      • short: short description is included, converted to text if was html
      • long: short and long description are included, converted to text they were html
      • html: full original short and long descriptions are included
    • wpts is a flag indicating whether or not additional waypoints should be included: 0 = no waypoints (default), 1 = include waypoints
    • logs is the maximum number of logs to include: 0 = none (default), 1 or more indicates the maximum number
    • tbs is a flag indicating whether or not cache inventory should be included: 0 = no waypoints (default), 1 = include TBs
  • Get nearest caches (Detail): a=nearest&maxcount=<max-count>&desc=<description-mode>&wpts=<wpts>&logs=<logs>&tbs=<tbs>
    • max-count is optional and specifies the maximum number of nearest caches to return in the gpx data. Default is 30.
    • all other parameters (desc, wpts, logs, tbs) are identical to Get cache detail section.