Getting status "REQUEST_DENIED" after fetching data from google places API

I have done that

    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://maps.googleapis.com/maps/api/place/search/json?location=30.722322,76.76126&radius=500&types=food&sensor=true&key=any_apiKey"]];

    NSURLResponse *response;
    NSError *error;
    NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
    NSString *strResponse = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
    NSLog(@"%@",strResponse);

    SBJSON *sbJason = [[SBJSON alloc] init];
    NSMutableDictionary *getPlaceList = [sbJason objectWithString:strResponse]; 

// But i am getting this-

   {
 "html_attributions" : [],
  "results" : [],
 "status" : "REQUEST_DENIED"
 }

**Is there any problem with API Key i have wrote API key given by google map. Is there any problem with api key or what please tell me here is the link of google api

Answers


The Static Maps API and the Places API each need to be enabled in the API Console for that key. Open the API console and enable access to the Places API. There is a Courtesy limit: 1,000 requests/day, after that you might need to enable billing.

https://code.google.com/apis/console/


Although this has been answered, I think the community could do better in explaining what ACTUALLY needs to be done in order to get this working.

I was tearing my hair out about this, it just didn't make sense to me.. I was making an iOS/Android App, so I made an iOS/Android Key... Wrong.

With Google's Places API, your bundle identifier isn't even considered.

What you really want to do is this: (I'm using the new User Interface)

1. Log into https://cloud.google.com/console#/project

Select your Project Name, then go into API's & Auth > APIs

Make sure you have Places API Turned on. This is the only thing that needs to be turned on for Places-API to work.

2. Go into Credentials

Click CREATE NEW KEY under Public API Access

3. Select BROWSER KEY

4. Click Create, Nothing Else

Leave the HTTP Refer box empty.

5. Use the Key Generated here

This key will allow ANY user from any device access to the API via your Developer login. You can try it out here: (Be sure to replace YOUR_KEY_HERE with your generated Key)

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Food%20Sh&sensor=false&radius=500&location=0,0&key=YOUR_KEY_HERE

6. Enjoy

Now you can use that URL above in your Android/iOS device.


Try using the BROWSER app key, not the iOS key. You can find it here:

https://code.google.com/apis/console/

And press "API Access" on the left


Just want to second Josh's solution. I have spent hours figuring out with the IOS key and almost gave up.


try this:-

https://developers.google.com/places/documentation/

Read following portion and proceed with the steps to obtain the key.

Authentication

The Google Places API uses an API key to identify your application. API keys are managed through the Google APIs console. You'll need your own API Key before you can begin using the API. To activate the Places API and create your key:

Visit the APIs console at https://code.google.com/apis/console and log in with your Google Account.
A default project called API Project is created for you when you first log in to the console. You can use the project, or create a new one by clicking the API Project button at the top of the window and selecting Create. Maps API for Business customers must use the API project created for them as part of their Places for Business purchase.
Click the Services link from the left-hand menu.
Click the Status switch next to the Places API entry. The switch slides to On.
Click API access from the left navigation. Your key is listed in the Simple API Access section.

I end up with this code.

UIActivityIndicatorView *activity=[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
activity.center=self.view.center;
[activity startAnimating];
[self.view addSubview:activity];


NSString *str=[[NSString alloc] init];
str=[NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/textsearch/json?query=%@&sensor=true&key=YOUR_BROWSER_KEY",searchQuery];
NSMutableURLRequest *request1=[[NSMutableURLRequest alloc] init];
NSURL *url= [[NSURL alloc] initWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[request1 setURL:url];
[request1 setHTTPMethod:@"GET"];

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

    NSError *requestError = nil;
    NSURLResponse *urlResponse = nil;
    NSData *response1 =
    [NSURLConnection sendSynchronousRequest:request1
                          returningResponse:&urlResponse error:&requestError];


    dispatch_async(dispatch_get_main_queue(), ^{


        if ([activity isAnimating]) {
            [activity startAnimating];
            [activity removeFromSuperview];
        }
        NSError* error;
        NSDictionary* json = [NSJSONSerialization JSONObjectWithData:response1
                                                             options:kNilOptions
                                                               error:&error];

        NSLog(@"%@",json);

        self.searchArray=[json objectForKey:@"results"];
        [self.tableView setDataSource:self];
        [self.tableView setDelegate:self];
        [self.tableView reloadData];

        [self showPins:self.searchArray];

    });
});

Need Your Help

WooCommerce require registration to buy

wordpress woocommerce

I need to require a user registration before buying a product. Right now, when you add a product to the cart, then in the check out you can fill all the fields with your information but without a

Can a .NET windows application be compressed into a single .exe?

.net windows

I am not too familiar with .NET desktop applications (using Visual Studio 2005). Is it possible to have the entire application run from a single .exe file?