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

ActiveLibrary[API Development](/categories/api)

hownowstephen/php-foursquare
============================

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

v1.2.0(11y ago)168177.3k↓67.2%661PHPPHP &gt;=5.2.0

Since Jul 3Pushed 6y ago20 watchersCompare

[ Source](https://github.com/hownowstephen/php-foursquare)[ Packagist](https://packagist.org/packages/hownowstephen/php-foursquare)[ RSS](/packages/hownowstephen-php-foursquare/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (3)Used By (1)

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 hownowstephen/php-foursquare:'1.2.*'

```

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 = $foursquare->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.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

43

—

FairBetter than 89% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity51

Moderate usage in the ecosystem

Community30

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 51.2% 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 ~340 days

Total

2

Last Release

4043d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7b58555cba60cb86d795903104dfc7cd0f2c44d31871f64bf6c9fa9be8928e75?d=identicon)[hownowstephen](/maintainers/hownowstephen)

---

Top Contributors

[![hownowstephen](https://avatars.githubusercontent.com/u/661424?v=4)](https://github.com/hownowstephen "hownowstephen (22 commits)")[![sojan-official](https://avatars.githubusercontent.com/u/73185?v=4)](https://github.com/sojan-official "sojan-official (3 commits)")[![babcca](https://avatars.githubusercontent.com/u/770147?v=4)](https://github.com/babcca "babcca (3 commits)")[![alexjs](https://avatars.githubusercontent.com/u/288572?v=4)](https://github.com/alexjs "alexjs (2 commits)")[![DaSchTour](https://avatars.githubusercontent.com/u/1907266?v=4)](https://github.com/DaSchTour "DaSchTour (2 commits)")[![danieltrolezi](https://avatars.githubusercontent.com/u/3670155?v=4)](https://github.com/danieltrolezi "danieltrolezi (2 commits)")[![segeda](https://avatars.githubusercontent.com/u/504956?v=4)](https://github.com/segeda "segeda (2 commits)")[![zackgilbert](https://avatars.githubusercontent.com/u/432526?v=4)](https://github.com/zackgilbert "zackgilbert (1 commits)")[![arminrosu](https://avatars.githubusercontent.com/u/612952?v=4)](https://github.com/arminrosu "arminrosu (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)")[![vojtasvoboda](https://avatars.githubusercontent.com/u/374917?v=4)](https://github.com/vojtasvoboda "vojtasvoboda (1 commits)")

---

Tags

foursquarefoursquare-libraryphp

### Embed Badge

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

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

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k15](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

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