作品中是否有api order_by/sort参数? [英] Is there an api order_by/sort parameter in the works?

查看:104
本文介绍了作品中是否有api order_by/sort参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果"order_by"&可以在api查询字符串中传递"sort"参数.

It would be extremely helpful if an "order_by" & "sort" parameter could be passed in the api querystring.

"order_by"应接受以下选项:签到|名称

"order_by" should accept the following options: distance | checkins | name

"sort"应该接受以下选项:asc | desc

"sort" should accept the following options: asc | desc

匹配的结果集应先应用order_by和sort参数,然后再将结果范围缩小到返回的最大"50"个结果.

The matched result set should have the order_by and sort parameters applied prior to narrowing the result set to the max "50" results that get returned.

这是在四方雷达上还是不会提供的东西?

Is this on the foursquare radar or is it something that will not be offered?

我们正在构建一个应用程序,使用户可以根据设备的地理位置查找离他们最近的餐厅".

We are building an app that lets users locate "restaurants" closest to them based on the device's geolocation.

我们遇到的问题是设置默认半径.我们首先将半径设置为3200米,希望这对于稀疏位置会在一定程度上返回一些结果,同时对于密集位置也会返回最接近的结果.

The issue we are having is in setting the default radius. We started by setting the radius to 3200 meters, hoping that that would return at lease some results for sparse locations while also returning the closest results for dense locations.

此方法适用于返回值小于50的位置,因为我们可以对后响应进行排序,但是在诸如华盛顿特区这样的密集区域中,当结果超过50个时,api决定返回的50值与最接近

This works for locations that return less than 50 because we can sort post response, but in a dense area such as Washington DC, when there are more than 50 results the 50 that the api decides to return are NOT the closest to the ll.

因此,我们必须按如下所示构造查询(这很糟糕,因为它需要对api进行多达7次点击)才能尝试找到接近50个结果的最佳点".

Therefore we have to structure our query as shown below (which sucks cause it requires upto 7 hits to the api) to try to find that "sweet spot" of just under 50 results.

这是我们在应用程序中靠近我"位置遇到的问题.尝试在应用程序中显示受欢迎的"场所时,我们也遇到类似的问题,但我将其保存在另一篇文章中.

This is the issue we are encountering for "near me" locations in our app. We have a similar issue when trying to display "popular" venues in the app, but I'll save that for another post.

ob_start();
require_once 'includes/EpiCurl.php';
require_once 'includes/EpiFoursquare.php';
$clientId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$clientSecret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$fsObjUnAuth = new EpiFoursquare($clientId, $clientSecret);

$time_start2 = microtime(true);

$result = $fsObjUnAuth->get('/venues/search', array(
'categoryId' => '4d4b7105d754a06374d81259',
'limit' => '50',
'radius' => '100',
'intent' => 'checkin',
'll' => $ll,
'v' => '20120211'
));
$result_count1 = count($result->response->venues);

if ($result_count1 < 30) {

    $result = $fsObjUnAuth->get('/venues/search', array(
        'categoryId' => '4d4b7105d754a06374d81259',
        'limit' => '50',
        'radius' => '200',
        'intent' => 'checkin',
        'll' => $ll,
        'v' => '20120211'
        ));

    $result_count2 = count($result->response->venues);

    if ($result_count2 < 30) {

        $result = $fsObjUnAuth->get('/venues/search', array(
            'categoryId' => '4d4b7105d754a06374d81259',
            'limit' => '50',
            'radius' => '400',
            'intent' => 'checkin',
            'll' => $ll,
            'v' => '20120211'
            ));

        $result_count3 = count($result->response->venues);

        if ($result_count3 < 30) {

            $result = $fsObjUnAuth->get('/venues/search', array(
                'categoryId' => '4d4b7105d754a06374d81259',
                'limit' => '50',
                'radius' => '800',
                'intent' => 'checkin',
                'll' => $ll,
                'v' => '20120211'
                ));
            $result_count4 = count($result->response->venues);

            if ($result_count4 < 30) {

                $result = $fsObjUnAuth->get('/venues/search', array(
                    'categoryId' => '4d4b7105d754a06374d81259',
                    'limit' => '50',
                    'radius' => '1200',
                    'intent' => 'checkin',
                    'll' => $ll,
                    'v' => '20120211'
                    ));

                $result_count5 = count($result->response->venues);

                if ($result_count5 < 30) {                
                    $result = $fsObjUnAuth->get('/venues/search', array(
                        'categoryId' => '4d4b7105d754a06374d81259',
                        'limit' => '50',
                        'radius' => '1600',
                        'intent' => 'checkin',
                        'll' => $ll,
                        'v' => '20120211'
                        ));
                    $result_count6 = count($result->response->venues);

                    if ($result_count6 < 30) {

                        $result = $fsObjUnAuth->get('/venues/search', array(
                            'categoryId' => '4d4b7105d754a06374d81259',
                            'limit' => '50',
                            'radius' => '3200',
                            'intent' => 'checkin',
                            'll' => $ll,
                            'v' => '20120211'
                            ));
                        $result_count7 = count($result->response->venues);
                    }
                }
            }
        }
    }
}

推荐答案

目前尚无计划提供此类参数.在大多数情况下,这些参数仅对开发人员抓取区域中的所有场所有用,这违反了foursquare 条款服务

There's no plan to offer such parameters. For the most part, these parameters are only useful for developers scraping all venues in a region, which is in violation of the foursquare terms of service

提供了三种不同的意图",它们对应于需要不同等级排序的有效用例.

There are three different "intents" offered which correspond to valid use cases requiring different types of ranking.

  • intent = 签入返回用户最多的场所列表 可能位于

  • intent=checkin returns a list of venues where the user is most likely is located

intent = 浏览返回有关以下内容的最相关场所的列表: 要求的区域,而不是到中心点的距离有偏差.

intent=browse returns a list of most relevant venues for a requested region, not biased by distance from a central point.

intent = 匹配返回单个结果,该结果具有较高的置信度, 是基于查询的请求的相应Foursquare场所

intent=match returns a single result that, with high confidence, is the corresponding foursquare venue for the query-based request

这篇关于作品中是否有api order_by/sort参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆