在工作中是否有api order_by/sort参数?

Rob*_*hes 5 foursquare

如果可以在api查询字符串中传递"order_by"和"sort"参数,那将非常有用.

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

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

匹配的结果集应该在将结果集缩小到返回的最大"50"结果之前应用order_by和sort参数.

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

我们正在构建一个应用程序,允许用户根据设备的地理位置找到离他们最近的"餐馆".

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

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

因此,我们必须构建我们的查询,如下所示(这很糟糕,因为它需要最多7次点击到api)才能找到不到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);
                    }
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

akd*_*com 1

目前还没有提供此类参数的计划。大多数情况下,这些参数仅对开发者抓取一个地区的所有场馆有用,这违反了 foursquare服务条款

提供了三种不同的“意图”,它们对应于需要不同类型排名的有效用例。

  • Intent= checkin返回用户最有可能所在的地点列表

  • 意图=浏览返回所请求区域的最相关场所的列表,不因距中心点的距离而产生偏差。

  • Intent= match返回单个结果,该结果具有高置信度,是基于查询的请求的相应 foursquare 地点