2017 © Pedro Peláez
 

library larasquare

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

image

iivannov/larasquare

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

  • Monday, October 5, 2015
  • by iivannov
  • Repository
  • 2 Watchers
  • 8 Stars
  • 1,006 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 7 % Grown

The README.md

Larasquare

Latest Version on Packagist ![Software License][ico-license] Total Downloads, (*1)

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

Install

Via Composer, (*3)

``` bash $ composer require iivannov/larasquare, (*4)



## Usage with Laravel To use the Laravel Facade you need to add the ServiceProvider and Facade classes in your `config\app.php` ``` 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, (*5)

``` php 'foursquare' => [ 'clientId' => YOUR_FOURSQUARE_CLIENT_ID, 'clientSecret' => YOUR_FOURSQUARE_CLIENT_SECRET ], (*6)


After this you can directly use the Laravel Facade ``` php $venues = Larasquare::venues($searchQuery);

Standard Usage

``` php $config = [ clientId = YOUR_FOURSQUARE_CLIENT_ID, clientSecretT = YOUR_FOURSQUARE_CLIENT_SECRET, apiUrl = FOURSQUARE_API_URL, //optional version = SUPPORTED_VERSION, //optional, format: YYYYMMDD ];, (*7)

$foursquare = new Foursquare($config);, (*8)

$venues = $foursquare->venues($searchQuery);, (*9)


## 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. ```php $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., (*10)


/** * 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., (*11)

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

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

** Searching Venues **, (*12)

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

** Get a single venue **, (*13)

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

** Other venues methods **, (*14)

// 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., (*15)

The Versions

05/10 2015

dev-master

9999999-dev https://github.com/iivannov/larasquare

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

  Sources   Download

MIT

The Requires

 

by Ivan Ivanov

laravel api client foursquare

02/10 2015

0.1.0

0.1.0.0 https://github.com/iivannov/larasquare

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

  Sources   Download

MIT

The Requires

 

by Ivan Ivanov

laravel api client foursquare