================================
A(nother) PHP Foursquare API client
https://developer.foursquare.com/docs/
Composer is currently the only way to install the foursquare client into your project.
{
"require": {
"thetwelvelabs/foursquare": "0.1.*@dev"
}
}
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar install
$client = new \TheTwelve\Foursquare\HttpClient\SymfonyHttpClient();
$factory = new \TheTwelve\Foursquare\ApiGatewayFactory($client);
// Required for most requests
$factory->setClientCredentials('CLIENT_ID', 'CLIENT_SECRET');
// Optional
$factory->setEndpointUri('https://api.foursquare.com');
$factory->useVersion(2);
$auth = $factory->getAuthenticationGateway(
'https://foursquare.com/oauth2/authorize',
'https://foursquare.com/oauth2/access_token',
'YOUR_REDIRECT_URL'
);
$auth->initiateLogin();
$code = $_GET['code'];
// You should do some input sanitization to $code here, just in case
$token = $authGateway->authenticateUser($code);
$factory->setToken($token);
$gateway = $factory->getUsersGateway();
$user = $gateway->getUser();
$gateway = $factory->getVenuesGateway();
$venues = $gateway->search(array(
'll' => '40.727198,-73.992289',
'query' => 'Starbucks',
'radius' => 1000,
'intent' => 'checkin'
));