你可以用这样的东西
/**
 *  Get City state from zipcode
 */
function rtp_get_city_state($location) {
    $details_url = \'http://maps.google.com/maps/api/geocode/json?address=\'.$location.\'&sensor=false\';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $details_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $response = json_decode(curl_exec($ch), true);
    if ($response[\'status\'] != \'OK\') {
        return null;
    }
    print_r($response);
}