This bundle integrates the JcrollFoursquareApiClient into the Symfony2 framework.
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.
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(),
...
);
...
}
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>
$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.
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.