First of all I want to say that I have checked all the related answers to this question and none of them is working for me as I think they are now old and doesn't seem to work with the new apis.
- How to use Google Places API in Android?
- Can i use google Places API in android?
- Google Places API - android
Above are the few links that I have checked.
I am trying to get the nearby restaurants using the places api in which radius will be defined by user using a seekbar. Here is how I am creating my request
private String getUrl(double latitude, double longitude, String nearbyPlace, int radius) {
StringBuilder googlePlacesUrl = new StringBuilder("https://maps.googleapis.com/maps/api/place/search/json?");
googlePlacesUrl.append("location=" + latitude + "," + longitude);
googlePlacesUrl.append("&radius=" + radius);
googlePlacesUrl.append("&type=" + "restaurants");
googlePlacesUrl.append("&sensor=true");
googlePlacesUrl.append("&keyword=" + nearbyPlace);
googlePlacesUrl.append("&key=" + "xxxxxxxxxxxxxx");
Log.d("getUrl", googlePlacesUrl.toString());
return (googlePlacesUrl.toString());
}
I pass the above created url to an asynctask to fetch the result from it.
But everytime I am trying to request I get the below error.
{ "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 103.226.226.47, with empty referer", "html_attributions" : [], "results" : [], "status" : "REQUEST_DENIED"}
I have signed up for google cloud platform too in case that is the issue but that doesn't help either.