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

本文是小编为大家收集整理的关于是否有一个api order_by/sort参数在工作中?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

如果可以在API querystring中传递" order_by"&" stort"参数,这将非常有帮助.

" order_by"应接受以下选项:距离|检查|名称

"排序"应接受以下选项:ASC | desc

匹配的结果集应具有order_by和排序参数,然后将结果集缩小到返回的最大" 50"结果.

这是在foursquare雷达上吗?还是不会提供的东西?

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

我们遇到的问题在于设置默认半径.我们首先将半径设置为3200米,希望能以稀疏位置的租赁结果返回,同时还可以返回密集位置的最接近结果.

这适用于返回少于50的位置,因为我们可以对后响应进行排序,但是在华盛顿特区的密集区域中,当有50个以上的结果时,API决定返回的50个以上的结果不是最接近的. ll.

因此,我们必须如下所示构造我们的查询(这很烂,因此需要对API进行7次命中),以便找到仅50个结果的"最佳点".

这是我们在应用程序中遇到的"附近"位置遇到的问题.在试图在应用程序中显示"流行"场地时,我们也有类似的问题,但是我将其保存在另一篇文章中.

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 术语服务

提供了三种不同的"意图",与需要不同类型排名的有效用例相对应.

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

  • intent = 浏览返回一个最相关场所的列表 请求的区域,不偏离中心点的距离.

  • intent = 匹配返回一个结果,置信度很高, 是基于查询的请求

  • 的相应foursquare场地

本文地址:https://www.itbaoku.cn/post/2090860.html

问题描述

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

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

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

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.

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.

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.

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);
                    }
                }
            }
        }
    }
}

推荐答案

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=checkin returns a list of venues where the user is most likely is located

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

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