Without needing any external API
UK Postcode data is now freely available from the Ordnance Survey CodePoint as a downloadable series of CSV files (Feb 2009); but unfortunately the location point is stored using Northing/Eastings rather than Latitude and Longitude.
You'd need to convert the Northings/Eastings to Latitude/Longitude. There's a number of articles about this on the web, e.g.
http://www.deepbluesky.com/blog/-/converting-os-coodinates-into-longitude-latitude_7/
http://mediakey.dk/~cc/convert-northing-and-easting-utm-to-longitude-and-latitude/
but you need to be aware that OS Northings/Eastings are based on the Airy 1830 ellipsoid rather than the WGS84 model used by Google maps (and most GSM systems). Failing to allow for this difference can put you out by anything between 70-120m between Cornwall and East Anglia.
Using PHP, the best solution for this conversion is PHPCoord by Jonathan Stott