Unable to get number of businesses with google map API

My plugin work is collecting data based on user input. If a user wants to know how much GLOSSARY business is there in London then they will have to input business type and area name.

Everything is fine in my plugin but i don’t know why the number of business is not showing. I was looking but extended version of this plugin here on the home page http://marketpot.co.uk
& what i have developed is here http://www.sparkcoder.com/wordpress/streetcheck/

Both plugins code i have but still i am not getting the business number data. Can anyone help me please ? My code for collecting info is here :


function sc_postcode_location($postcode){
	global $googlekey;
	$postcode=str_replace(" ", "", $postcode);
	
	$output=get_option(md5($postcode));
	$output="";
	
	if(empty($output)){
		$url = "https://maps.googleapis.com/maps/api/geocode/json?address=$postcode&key=$googlekey&components=country:GB";
		$geocode = file_get_contents($url);
		$geocode = json_decode($geocode, true);

		$location = $geocode["results"][0]["geometry"]["location"];
		
		if(isset($location["lat"]) && isset($location["lng"])){
			$output=array($location["lat"], $location["lng"]);
			update_option(md5($postcode), $output);
		}
	}
	
	return $output;
}


function sc_search_places($args=array()){
	global $googlekey;

	$location=$args["location"];
	$radius=$args["radius"];
	$type=$args["type"];
	$type=urlencode($type);

	$output=[];
	if(empty($output)){
		
		$url = "https://maps.googleapis.com/maps/api/place/radarsearch/json?keyword=$type&location=$location&radius=$radius&key=$googlekey";
		//AIzaSyCQ9gF6NQSnFD-eflx-QqDWYnbJpm8EtXw
		@$places = file_get_contents($url);
		
		$places = json_decode($places, true);
		
		if(isset($places["results"])){
			foreach ($places["results"] as $key => $value) {
				     $place_detail = sc_place_details($value['place_id']);
				     $places["results"][$key]['name'] = $place_detail['name']; 
				$output =  $places ;   
			}
		}
	}
	
	return $output;
}

function sc_place_details($place_id){
	global $googlekey;
	
	$url = "https://maps.googleapis.com/maps/api/place/details/json?placeid=$place_id&key=$googlekey";
	@$placeDetails = file_get_contents($url);
	
	$placeDetails = json_decode($placeDetails, true);
	
	if(isset($placeDetails["result"])){
		return $placeDetails["result"];
	}
	else{
		return array();
	}
}

Thank you.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.