承接 iivannov/larasquare 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

iivannov/larasquare

最新稳定版本:0.1.0

Composer 安装命令:

composer require iivannov/larasquare

包简介

Simple and extensible Foursquare API PHP Client with Laravel Support based on Guzzle 6

README 文档

README

Latest Version on Packagist Software License Total Downloads

Simple and extensible Foursquare API PHP Client with Laravel Facade and ServiceProvider based on Guzzle 6 Currently it supports only userless endpoint requests.

Install

Via Composer

$ composer require iivannov/larasquare

Usage with Laravel

To use the Laravel Facade you need to add the ServiceProvider and Facade classes in your config\app.php

'providers' => [
    ...
    Iivannov\Larasquare\Provider\LarasquareServiceProvider::class,
];

'aliases' => [
    ...
    'Larasquare' => Iivannov\Larasquare\Facade\Larasquare::class
];

You need to add your Foursquare client ID and secret in config\services.php

'foursquare' => [
    'clientId' => YOUR_FOURSQUARE_CLIENT_ID,
    'clientSecret' => YOUR_FOURSQUARE_CLIENT_SECRET
]

After this you can directly use the Laravel Facade

$venues = Larasquare::venues($searchQuery);

Standard Usage

$config = [
    clientId = YOUR_FOURSQUARE_CLIENT_ID,
    clientSecretT = YOUR_FOURSQUARE_CLIENT_SECRET,
    apiUrl = FOURSQUARE_API_URL, //optional
    version = SUPPORTED_VERSION, //optional, format: YYYYMMDD
];

$foursquare = new Foursquare($config);

$venues = $foursquare->venues($searchQuery);

Query filters

If you need to generate, filter or transform your search query you can extract all the logic in a separate class that implements the Iivannov\Larasquare\Filter\FilterContract and then just inject it with setFilter() method.

$venues = Larasquare::setFilter(new MyFilter())->venues();

Put your filter logic in the parse() method. It will automatically receive the query passed in the search methods. You can overwrite values, generate values from your custom array or whatever you need. The returned array will be sent with the Foursquare request.

/**
* Generate, transform or filter your search query
*
* @param $query
* @return array
*/
public function parse($query = [])
{
    return [
        'll' => $query['location']['lat'] . ',' . $query['location']['lon'],
        'query' => $query['searchTerm'],
        'near' => $_GET['nearLocation'],
        'radius' => 200
    ];
}

Methods

** Endpoints not covered by this library ** You can use the request method to query a Foursquare endpoint.

// get venue photos
$response = Larasquare::request("venues/$venueId/photos")

// get details about a tip,
$response = Larasquare::request("tips/$tipId")

** Searching Venues **

//Laravel
$venues = Larasquare::venues($query);

** Get a single venue **

$venues = Larasquare::venue($venueId);

** Other venues methods **

// get suggestion @see https://developer.foursquare.com/docs/venues/suggestcompletion
$venues = Larasquare::suggest($searchQuery);

// get trending @see https://developer.foursquare.com/docs/venues/trending
$venues = Larasquare::trending($searchQuery);

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 5.07k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 2
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-10-02