簡體   English   中英

狀態代碼:YELP api 中的 400

[英]status code: 400 in YELP api

我正在我的應用程序中進行 Yelp 集成,我正在使用這個演示作為參考。

當我搜索@"restaurants"它運行良好,但是當我搜索@"Shopping"它給出了以下響應:

{ 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";
} }

我的.m文件代碼:

- (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
    }

有誰知道 Yelp API 中的問題是什么?

那是因為您正在使用和構建的項目是基於 API 1.0 構建的。 文檔說得很清楚:

Yelp v1.0 API 已棄用,強烈建議開發人員不要使用它。 目前沒有關閉它的計划,但使用它需要您自擔風險。

看看這個問題和這個問題。 它們不完全是“做這個和這個”類型的問題,但它們確實提供了一些見解。 除此之外,我只能建議您仔細閱讀Yelp 文檔並相應地編寫您的應用程序。 只需使用AFNetworking來執行您想要的所有請求,一切都應該沒問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM