PHP Foursquare Api Client built on Guzzle

v1.0.3 2013-08-09 16:24 UTC


Build Status

Find the Symfony2 Bundle for this library here.


There is no library currently built to interact with the foursquare api using the fantastic Guzzle HTTP Client library. Guzzle is awesome and supplies a lot of great things for building web service clients. Guzzle is fully unit tested which allows this library to be a light wrapper around the Guzzle core. You can read more about Guzzle here.


The JcrollFoursquareApiClient is available on Packagist (jcroll/foursquare-api-client) and as such installable via Composer.

If you do not use Composer, you can grab the code from GitHub, and use any PSR-0 compatible autoloader (e.g. the Symfony2 ClassLoader component) to load the library's classes.

Composer example

Add JcrollFoursquareApiBundle in your composer.json:

    "require": {
        "jcroll/foursquare-api-client": "1.0.*"

Download the library:

$ php composer.phar update jcroll/foursquare-api-client

After installing, you need to require Composer's autoloader somewhere in your code:

require_once 'vendor/autoload.php';


use Jcroll\FoursquareApiClient\Client\FoursquareClient;

$client = FoursquareClient::factory(array(
    'client_id'     => 'your_foursquare_client_id',    // required
    'client_secret' => 'your_foursquare_client_secret' // required
$client->addToken($oauthToken); // optionally pass in for user specific requests
$command = $client->getCommand('venues/search', array(
    'near' => 'Chicago, IL',
    'query' => 'sushi'
$results = $command->execute(); // returns an array of results

You can find a list of the client's available commands in the bundle's client.json but basically they should be the same as the api endpoints listed in the docs.

Oauth Integration

Endpoints in the foursquare API that are user specific will require authorization with foursquare using the Oauth 2.0 protocol. This type of authorization is beyond the scope of this library as there are better libraries for that such as the FriendsOfSymfony Oauth2 Server. After authorization you can pass the access token into the client for user specific access.