-1

I am working on Yelp integration in my app and I am using this demo as a reference.

When I am searching @"restaurants" it works well, but when I am searching @"Shopping" it gives this response:

{ status code: 400, headers {
    "Cache-Control" = private;
    "Content-Length" = 123;
    "Content-Type" = "application/json; charset=UTF-8";
    Date = "Mon, 06 Jul 2015 10:28:37 GMT";
    Server = Apache;
    Vary = "User-Agent";
    "X-Mode" = ro;
    "X-Node" = "web16-uswest1bprod, api_com";
    "X-Proxied" = "extlb1-uswest1bprod";
} }

My .m file code:

- (OAMutableURLRequest*) getOARequest {
    NSString *realm;

    OAConsumer *consumer = [[OAConsumer alloc] initWithKey: CONSUMER_KEY secret: CONSUMER_SECRET];


     //passing token and token secret keys.

    OAToken *token = [[OAToken alloc] initWithKey: TOKEN secret: TOKEN_SECRET]; 
    id<OASignatureProviding, NSObject> provider = [[OAHMAC_SHA1SignatureProvider alloc] init];



    //calling signature method
    OAMutableURLRequest* request = [[OAMutableURLRequest alloc] 
                                    initWithURL: [NSURL URLWithString:[self getRequestURLString]]
                                    consumer: consumer
                                    token: token
                                    realm: realm
                                    signatureProvider: provider];
    [request prepare];
    return request;
}

- (void) getRestaurantList {
    NSHTTPURLResponse* response;    //this is object is used for response perpose
    NSError* error;

    NSData* data = [NSURLConnection sendSynchronousRequest: [self getOARequest] 
                                         returningResponse: &response 
                                                     error: &error];

    // If the response is all good then fill in the restaurant dictionary with
    // the Yelp JSON data


    NSLog(@"%@",response);

    if ([response statusCode] == 200) {
        //success
    }

Does anyone know what is the problem in the Yelp API?

Michal
  • 15,429
  • 10
  • 73
  • 104
Krish Solanki
  • 269
  • 4
  • 11

1 Answers1

2

That's because the project you are using and building upon is built on API 1.0. The documentation says it quite clearly:

The Yelp v1.0 API is deprecated and it is strongly recommended that developers not use it. There are no current plans to turn it off but using it is at your own risk.

Take a look at this question and this one too. They are not exactly "do this and this" kind of questions, but they do provide some insight. Other than that, I can only recommend reading carefully the Yelp documentation and write your app accordingly. Simply use AFNetworking to do all the requests you want and everything should be fine.

Community
  • 1
  • 1
Michal
  • 15,429
  • 10
  • 73
  • 104
  • Ok then why it is working with "Food" categories and not working in "Shopping"? my q is this man ! – Krish Solanki Jul 06 '15 at 10:57
  • Because the API is not maintained anymore. They could have shut that category down. They have no responsibility for it anymore as it is deprecated. – Michal Jul 06 '15 at 11:00
  • Shopping iteslf still is in the API 2.0 (https://www.yelp.com/developers/documentation/v2/all_category_list), so it *could* work, but you can never know. It looks like it's case sensitive - have you tried `shopping` instead of `Shopping`? – Michal Jul 06 '15 at 11:13
  • I am using v2 but still getting same issue . – Alok Sep 04 '15 at 08:56