Warning while using file_get_contents for google api

后端 未结 5 915
刺人心
刺人心 2020-12-17 06:49

I am using this code for finding the lat lon of a location

$api=\'http://maps.googleapis.com/maps/api/geocode/json?address=United States Neversink&sensor         


        
5条回答
  •  长情又很酷
    2020-12-17 07:00

    Use urlencode to encode the address part. (The problem is the space in the address.)

    $address = urlencode("United States Neversink");
    $api='http://maps.googleapis.com/maps/api/geocode/json?address=$address&sensor=false';
    
    $result = file_get_contents($api);
    

提交回复
热议问题