PHPackages                             thetwelvelabs/foursquare - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. thetwelvelabs/foursquare

ActiveLibrary[API Development](/categories/api)

thetwelvelabs/foursquare
========================

Foursquare API Client

v0.2.2(11y ago)3790.7k141MITPHPPHP &gt;=5.3.3

Since Feb 26Pushed 11y ago7 watchersCompare

[ Source](https://github.com/chriswoodford/foursquare-php)[ Packagist](https://packagist.org/packages/thetwelvelabs/foursquare)[ Docs](http://thetwelvelabs.com)[ RSS](/packages/thetwelvelabs-foursquare/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (7)Used By (1)

Foursquare API Client
=====================

[](#foursquare-api-client)

A(nother) PHP Foursquare API client

Installation
------------

[](#installation)

[Composer](http://getcomposer.org) is currently the only way to install the foursquare client into your project.

### Create your composer.json file

[](#create-your-composerjson-file)

```
  {
      "require": {
          "thetwelvelabs/foursquare": "0.2.*"
      }
  }

```

### Download composer into your application root

[](#download-composer-into-your-application-root)

```
  $ curl -s http://getcomposer.org/installer | php

```

### Install your dependencies

[](#install-your-dependencies)

```
  $ php composer.phar install

```

Usage
-----

[](#usage)

### Select your preferred HTTP Client (CurlHttpClient is the default)

[](#select-your-preferred-http-client-curlhttpclient-is-the-default)

```
  $client = new \TheTwelve\Foursquare\HttpClient\CurlHttpClient($pathToCertificateFile);

```

### Select your preferred Redirector (HeaderRedirector is the default)

[](#select-your-preferred-redirector-headerredirector-is-the-default)

```
  $redirector = new \TheTwelve\Foursquare\Redirector\HeaderRedirector();

```

Note: The redirector is optional and is only needed if you need Foursquare authentication

### Instantiate the API Gateway Factory

[](#instantiate-the-api-gateway-factory)

```
  $factory = new \TheTwelve\Foursquare\ApiGatewayFactory($client, $redirector);

  // Required for most requests
  $factory->setClientCredentials('CLIENT_ID', 'CLIENT_SECRET');

  // Optional (only use these if you know what you're doing)
  $factory->setEndpointUri('https://api.foursquare.com');
  $factory->useVersion(2);
  $factory->verifiedOn(new \DateTime());

```

### Begin authentication with Foursquare

[](#begin-authentication-with-foursquare)

```
  $auth = $factory->getAuthenticationGateway(
      'https://foursquare.com/oauth2/authorize',
      'https://foursquare.com/oauth2/access_token',
      'YOUR_REDIRECT_URL'
  );

  $auth->initiateLogin();

```

### Foursquare redirects the user back to you after a successful login

[](#foursquare-redirects-the-user-back-to-you-after-a-successful-login)

```
  $code = $_GET['code'];

  // You should do some input sanitization to $code here, just in case

  $token = $auth->authenticateUser($code);

```

### Update the API Gateway Factory with your OAuth token

[](#update-the-api-gateway-factory-with-your-oauth-token)

```
  $factory->setToken($token);

```

### Get an instance of an endpoint gateway

[](#get-an-instance-of-an-endpoint-gateway)

```
  $gateway = $factory->getUsersGateway();

```

### Get data from Foursquare

[](#get-data-from-foursquare)

```
  $user = $gateway->getUser();

```

### Search venues

[](#search-venues)

```
  $gateway = $factory->getVenuesGateway();

  $venues = $gateway->search(array(
    'll' => '40.727198,-73.992289',
    'query' => 'Starbucks',
    'radius' => 1000,
    'intent' => 'checkin'
  ));

```

Working With Symfony / Silex
----------------------------

[](#working-with-symfony--silex)

If you're working with Symfony or Silex, you can use the Symfony HttpClient and Redirector

```
  $client = new \TheTwelve\Foursquare\HttpClient\SymfonyHttpClient($pathToCertificateFile);
  $redirector = new \TheTwelve\Foursquare\Redirector\SymfonyRedirector();

```

If you're working with Silex, there is a Service Provider available at

Using the CurlHttpClient
------------------------

[](#using-the-curlhttpclient)

If you're using the CurlHttpClient, you will probably want to include the cacert.pem file that can be found at

You can add this as a dependency in your composer file. Your `composer.json` might look something like this:

```
  {
      "require": {
          "thetwelvelabs/foursquare": "0.2.*",
          "haxx-se/curl": "1.0.0"
      },
      "repositories": [
          {
              "type": "package",
              "package": {
                  "name": "haxx-se/curl",
                  "version": "1.0.0",
                  "dist": {
                      "url": "http://curl.haxx.se/ca/cacert.pem",
                      "type": "file"
                  }
              }
          }
      ]
  }

```

You will be able to find the cacert.pem file in `vendor/haxx-se/curl/cacert.pem`

Contributing
------------

[](#contributing)

See [CONTRIBUTING.md](https://github.com/chriswoodford/foursquare-php/blob/master/CONTRIBUTING.md)

License
-------

[](#license)

This library is released under the [MIT License](http://www.opensource.org/licenses/MIT).

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~103 days

Recently: every ~126 days

Total

6

Last Release

4308d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a2d84b3d83f9fbf406a9702429df0cfb0b904836d86cc13870a31d5ead9f1597?d=identicon)[chriswoodford](/maintainers/chriswoodford)

---

Top Contributors

[![chriswoodford](https://avatars.githubusercontent.com/u/249055?v=4)](https://github.com/chriswoodford "chriswoodford (98 commits)")[![kisPocok](https://avatars.githubusercontent.com/u/434719?v=4)](https://github.com/kisPocok "kisPocok (3 commits)")[![vojtasvoboda](https://avatars.githubusercontent.com/u/374917?v=4)](https://github.com/vojtasvoboda "vojtasvoboda (3 commits)")[![quard8](https://avatars.githubusercontent.com/u/318700?v=4)](https://github.com/quard8 "quard8 (3 commits)")[![fedeisas](https://avatars.githubusercontent.com/u/251675?v=4)](https://github.com/fedeisas "fedeisas (2 commits)")[![komapa](https://avatars.githubusercontent.com/u/577?v=4)](https://github.com/komapa "komapa (2 commits)")[![sl4mmer](https://avatars.githubusercontent.com/u/1143307?v=4)](https://github.com/sl4mmer "sl4mmer (1 commits)")[![snowwons](https://avatars.githubusercontent.com/u/5221891?v=4)](https://github.com/snowwons "snowwons (1 commits)")

---

Tags

foursquare

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/thetwelvelabs-foursquare/health.svg)

```
[![Health](https://phpackages.com/badges/thetwelvelabs-foursquare/health.svg)](https://phpackages.com/packages/thetwelvelabs-foursquare)
```

###  Alternatives

[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)[hubspot/api-client

Hubspot API client

23414.2M16](/packages/hubspot-api-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
