PHPackages                             gilberg-vrn/php-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. gilberg-vrn/php-foursquare

ActiveLibrary[API Development](/categories/api)

gilberg-vrn/php-foursquare
==========================

A simple PHP library for accessing the foursquare API (see: https://developer.foursquare.com)

1.1.8(11y ago)17.0k↓41.7%PHPPHP &gt;=5.4.0

Since Jul 3Pushed 11y ago2 watchersCompare

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

READMEChangelog (3)DependenciesVersions (7)Used By (0)

Why another Foursquare library?
-------------------------------

[](#why-another-foursquare-library)

I couldn't find a php library for the Foursquare API that encapsulated all the functionality of the API while still remaining easy to plug in to an application quickly. This library seeks to fill that need.

### Installation

[](#installation)

The best way to install Foursquare library is to use [Composer](https://getcomposer.org/):

```
composer require gilberg-vrn/php-foursquare:'1.1.*'

```

If you are not using an autoloader, you need to require\_once the autoload file:

```
require_once 'vendor/autoload.php';

```

Another way to install is to download the latest version directly from this repository.

### Usage

[](#usage)

This library wrappers for php applications to make requests to both public and authenticated-only resources on Foursquare. As well it provides functions that encapsulate the main methods needed to retrieve an auth\_token for a user from Foursquare. Instead of having explicit functions for calling API endpoints, you can call individual endpoints directly by their path (eg. [venues/40a55d80f964a52020f31ee3/tips](https://api.foursquare.com/v2/venues/40a55d80f964a52020f31ee3/tips))

#### Querying the API

[](#querying-the-api)

```
$foursquare = new FoursquareApi("", "");

// Searching for venues nearby Montreal, Quebec
$endpoint = "venues/search";

// Prepare parameters
$params = array("near"=>"Montreal, Quebec");

// Perform a request to a public resource
$response = $foursquare->GetPublic($endpoint,$params);

// Returns a list of Venues
// $POST defaults to false
$venues = $api->GetPublic($endpoint [,$params], $POST=false);

// Note: You don't need to add client_id, client_secret, or version to $params

// Setting the access token to enable private requests
// See examples/tokenrequest.php for how to retrieve this
$auth_token = "";
$foursquare->SetAccessToken($auth_token);

// Request a private endpoint (Requires Acting User)
$endpoint_private = "users/self";

// Returns a single user object
$me = $foursquare->GetPrivate($endpoint_private);
// Note: You don't need to add oauth_token to $params
```

#### Authenticating the user (see [examples/tokenrequest.php](examples/tokenrequest.php))

[](#authenticating-the-user-see-examplestokenrequestphp)

```
$foursquare = new FoursquareApi("", "");

// Some real url that accepts a foursquare code (see examples/tokenrequest.php)
// This URL should match exactly the URL given in your foursquare developer account settings
$redirect_url = "http://localhost/foursquare_code_handler";

// Generates an authentication link for you to display to your users
// (https://foursquare.com/oauth2/authenticate?...)
$auth_link = $foursquare->AuthenticationLink($redirect_url);

// Converts an authentication code (sent from foursquare to your $redirect_url) into an access token
// Use this on your $redirect_url page (see examples/tokenrequest.php for more)
$code = $_GET['code'];

$token = $foursquare->GetToken($code, $redirect_url);

// again, redirect_url must match the one you set in your account exactly
// and here is where you would store the token for future usage
```

### Adding features &amp; testing

[](#adding-features--testing)

If you want to commit features, please also update the [tests/FoursquareApiTest.php](tests/FoursquareApiTest.php) file with a proper unit test - this will ensure changes can be accepted more quickly.

Running tests requires phpunit, and can be run as the following:

```
export FOURSQUARE_CLIENT_ID=
export FOURSQUARE_CLIENT_SECRET=
export FOURSQUARE_TOKEN=
phpunit --bootstrap src/FoursquareApi.class.php tests/FoursquareApiTest.php

```

**PROTIP**: The easiest way to get an access token to test with is to [look yourself up in the api explorer](https://developer.foursquare.com/docs/explore#req=users/self) and pull it directly from the grayed-out url information (OAuth token automatically added. [https://api.foursquare.com/v2/users/self?oauth\_token=](https://api.foursquare.com/v2/users/self?oauth_token=)...) underneath the input box.

### What else do I need?

[](#what-else-do-i-need)

This library does not deal with the management of your tokens - only the interaction between your code and the Foursquare API. If you are using it in an application that needs to use user data via an auth\_token, you will need to store the token across sessions separately from the library.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~58 days

Recently: every ~10 days

Total

6

Last Release

4046d ago

PHP version history (2 changes)v1.1.0PHP &gt;=5.2.0

v1.1.1PHP &gt;=5.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/a390972709926610b450a7cc525294bc335092643533690723ad226a50e947d7?d=identicon)[gilberg-vrn](/maintainers/gilberg-vrn)

---

Top Contributors

[![gilberg-vrn](https://avatars.githubusercontent.com/u/11310253?v=4)](https://github.com/gilberg-vrn "gilberg-vrn (16 commits)")[![hownowstephen](https://avatars.githubusercontent.com/u/661424?v=4)](https://github.com/hownowstephen "hownowstephen (11 commits)")[![babcca](https://avatars.githubusercontent.com/u/770147?v=4)](https://github.com/babcca "babcca (3 commits)")[![sojan-official](https://avatars.githubusercontent.com/u/73185?v=4)](https://github.com/sojan-official "sojan-official (3 commits)")[![DaSchTour](https://avatars.githubusercontent.com/u/1907266?v=4)](https://github.com/DaSchTour "DaSchTour (2 commits)")[![segeda](https://avatars.githubusercontent.com/u/504956?v=4)](https://github.com/segeda "segeda (2 commits)")[![vojtasvoboda](https://avatars.githubusercontent.com/u/374917?v=4)](https://github.com/vojtasvoboda "vojtasvoboda (1 commits)")[![CNG](https://avatars.githubusercontent.com/u/282056?v=4)](https://github.com/CNG "CNG (1 commits)")[![johntron](https://avatars.githubusercontent.com/u/131961?v=4)](https://github.com/johntron "johntron (1 commits)")[![matejvelikonja](https://avatars.githubusercontent.com/u/1881087?v=4)](https://github.com/matejvelikonja "matejvelikonja (1 commits)")[![Tmin10](https://avatars.githubusercontent.com/u/1534088?v=4)](https://github.com/Tmin10 "Tmin10 (1 commits)")[![arminrosu](https://avatars.githubusercontent.com/u/612952?v=4)](https://github.com/arminrosu "arminrosu (1 commits)")

### Embed Badge

![Health badge](/badges/gilberg-vrn-php-foursquare/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

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

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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