Question: I have a PHP script at the moment which allows users to enter a UK postcode.

I was wondering if there was a way I could get their geolocation from the postcode they enter. (Through Google's API or something?)

I have tried <http://code.google.com/apis/maps/documentation/geocoding/index.html> but it requires a full address, whereas I only have a postcode.

Help would be appreciated, thanks :)
Peter

Answer: 
You could check out the Yahoo PlaceFinder API 

Heres an example URL [http://where.yahooapis.com/geocode?q=BL12DD&appid=[yourappidhere]](http://where.yahooapis.com/geocode?q=BL12DD&appid=%5Byourappidhere%5D)

I have used this in the past and found it to be somewhat accurate.

Docs: <http://developer.yahoo.com/geo/placefinder/>

Heres come code

```
<?php

    $data = fetchPage("http://where.yahooapis.com/geocode?q=BL12DD&appid=%5Byourappidhere%5D&flags=J");
    $yahooData = json_decode($data);

    echo '<pre>'.print_r($yahooData, true).'</pre>';

    echo '<br />Lat: ' . $yahooData->ResultSet->Results[0]->latitude;

     function fetchPage($url){
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
    }

?>

```
Though this is already answered:
here is a link for a simple API that allows obtaining GeoJson for googlemaps..query by single or combining UK Postal Code(ex. ZE1 0AE) ,Sector, District, City, and Wards Boundaries

<https://www.mashape.com/vanitysoft/uk-boundaries-io>

[![query by uk postal](https://i.stack.imgur.com/uGF32.png)](https://i.stack.imgur.com/uGF32.png)