Ord’s Blog
RSS icon Home icon
  • Geocoding in PHP with Microsoft’s API

    Posted on February 24th, 2009 Ord 2 comments

    Yesterday I looked at using the Google Map API to geocode some addresses – today I examined the same using Microsoft’s API.

    The Microsoft API is somewhat more complicated to use, as it is a SOAP API we can’t just fetch and parse HTTP as we could with Google.

    To use these services with PHP, we need SOAP functions.  The server I had available to test had an old version of PHP (4.4), which doesn’t have this functionality built in.  It is easily added through the nusoap package.  Even with a later version of PHP that inclused SOAP functionality we might want to use nusoap anyway.

    Microsoft has a technical article showing exactly how to geocode an address using  their MapPoint web services in PHP.  I think it’s actually the only piece of PHP sample code in the whole Virtual Earth documentation, and it happens to be for Geocoding – lucky me.   The code as is runs fine, and it’s easy to understand.

    Before doing any of this, you will need to get an evaluation developers account opened.