I am fetching near by Bar,ATM,Cafe from user location using google place api. It is not fetching any location, but giving an error description.
Error description
This API project is not authorized to use this API. Please ensure that this API is activated in the APIs Console: Learn more: https://code.google.com/apis/console
Code:
- (IBAction)toolBarButtonPress:(id)sender {
UIBarButtonItem *button=(UIBarButtonItem*)sender;
NSString *buttonTitle=[button.title lowercaseString];
[self queryGooglePlaces:buttonTitle];
}
-(void)queryGooglePlaces:(NSString*)googleType {
NSString *url=[NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/json?location=%f,%f&radius=%@&types=%@&sensor=true&key=%@", -22.0, 137.0, [NSString stringWithFormat:@"%i", 1000], googleType, kGOOGLE_API_KEY];
// Here kGOOGLE_API_KEY is the api key, I have created
NSURL *googleResultsURL=[NSURL URLWithString:url];
NSData *data=[NSData dataWithContentsOfURL:googleResultsURL];
NSError* error;
if(!(data==nil))
{
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:data
options:kNilOptions
error:&error];
NSArray* places = [json objectForKey:@"error_message"];
//Write out the data to the console.
NSLog(@"Google Data: %@", places);
}
else
{
NSLog(@"Network error");
}
}
Can any one explain why it is showing this error?