Google place API in iOS application

时间:2015-06-30 13:41:52

标签: ios api google-places-api

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?

0 个答案:

没有答案