jcroll/foursquare-api-bundle

Symfony2 bundle for the jcroll/foursquare-api-client

Installs: 6 257

Dependents: 0

Stars: 5

Watchers: 4

Forks: 2

Language: PHP

v1.0.1 2013-08-06 15:46 UTC

README

Build Status

This bundle integrates the JcrollFoursquareApiClient into the Symfony2 framework.

Why?

There is no library 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.

Installation

Add JcrollFoursquareApiBundle in your composer.json:

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

Download bundle:

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

Add the JcrollFoursquareApiBundle to your AppKernel.php

// app/AppKernel.php

    public function registerBundles()
    {
        $bundles = array(
            ...
            new Jcroll\FoursquareApiBundle\JcrollFoursquareApiBundle(),
            ...
        );
        ...
    }

Basic configuration

Add your application id and secret parameters:

# app/config/config.yml

jcroll_foursquare_api:
    client_id:     <your_foursquare_client_id>
    client_secret: <your_foursquare_client_secret>

Usage

$client = $this->container->get('jcroll_foursquare_client');
$client->addToken($oauthToken); // optional for user specific requests
$command = $client->getCommand('venues/search', array(
    'near' => 'Chicago, IL',
    'query' => 'sushi'
));
$results = $command->execute();

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.

Oauth2 Integration

Authorization for user specific requests at foursquare via the Oauth 2 protocol is beyond the scope of this bundle. Here are two libraries you might use to do that:

After you receive your access token you can then pass it into the client as shown above.