有没有办法使用 Foursquare API 按价格搜索场地?

Is there a way to search venues by price using the Foursquare API?

我正在使用 Foursquare API this API 和 SwiftyJSON 在 Swift 中创建一个 iOS 项目。有什么方法可以获得与特定价格等级相匹配的 Venue 结果?

我了解如何接收包括价格等级在内的场地结果,但是,除了检查价格等级并过滤掉相关的之外,我不确定如何接收仅与特定价格等级匹配的场地。

编辑: 我当前的代码如下所示:

 func setUpFoursquare(){
    let client = FoursquareAPIClient(clientId: "JMBLK0SDZ0N2NF5TG3UCLMOF4FA5FKA14AIOZ4P4TS4MHEWO", clientSecret: "*****")

    let parameter: [String: String] = [
        "near": "Toronto",//destination!,
        "limit": "4",
        "query": "sushi",
        "price": "1",
        ];
    print("Parameter: \(parameter)");
    print("client: \(client)");
    //The path is based on the request link. For example, the request link for photos is:
    //GET https://api.foursquare.com/v2/venues/VENUE_ID/photos
    //So the path would correspond tovenues/VENUE_ID/photos where VENUE_ID is the corresponding ID.
    client.request(path: "venues/search", parameter: parameter) { result in
        //        client.request(path: "venues/categories", parameter: parameter) { result in

        switch result {
        case let .success(data):
            print("Success")
            guard let json = try? JSON(data: data) else{
                print("\(#function): Unable to retrieve json object")
                return
            }
            print("Json: \(json)")
            if json["meta"]["code"] == 200{
                self.parse(jsonObject: json)
            }
        case let .failure(error):
            // Error handling
            switch error {
            case let .connectionError(connectionError):
                print(connectionError)
            case let .responseParseError(responseParseError):
                print(responseParseError)   // e.g. JSON text did not start with array or object and option to allow fragments not set.
            case let .apiError(apiError):
                print(apiError.errorType)   // e.g. endpoint_error
                print(apiError.errorDetail) // e.g. The requested path does not exist.
            }
        }//end switch
    }//end client.request


}

然而 "price":"1" 参数实际上并没有改变结果。

使用 venues/explore 端点,您可以按价格等级过滤结果。请参阅此处的文档:https://developer.foursquare.com/docs/api/venues/explore

具体来说,您需要使用price参数:

Comma separated list of price points. Currently the valid range of price points are [1,2,3,4], 1 being the least expensive, 4 being the most expensive. For food venues, in the United States, 1 is < an entree, 2 is - an entree, 3 is - an entree, 4 is > an entree.

使用您链接到的 API 包装器,看起来像这样...

let parameter: [String: String] = [
    "ll": "35.702069,139.7753269",
    "limit": "10",
    "price": "1,2"
];

client.request(path: "venues/explore", parameter: parameter) { result in
    // do your SwiftyJSON stuff
}