Download the PHP package pdiazdumont/foursquare-api-php-wrapper without Composer
On this page you can find all versions of the php package pdiazdumont/foursquare-api-php-wrapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pdiazdumont/foursquare-api-php-wrapper
More information about pdiazdumont/foursquare-api-php-wrapper
Files in pdiazdumont/foursquare-api-php-wrapper
Package foursquare-api-php-wrapper
Short Description Foursquare API PHP Wrapper
License MIT
Homepage https://github.com/pdiazdumont/foursquare-api-php-wrapper
Informations about the package foursquare-api-php-wrapper
Foursquare API PHP Wrapper
Introduction
This project offers a more semantic way of accessing the Foursquare API using PHP. Instead of just wrapping the http requests it allows you to access the information using the following syntax:
Features:
- Full support of the Foursquare API including the Real time API.
- Compatible with the PSR-4 standard.
- Friendly commands to query the API.
Installation
This library can be installed using Composer by running the following command:
Usage
There are three use cases: requesting an access token from a user, querying the API and accessing the real time data. All these cases require the same code of initialization:
Initialization
Require the autoloader in order to make all the wrapper classes available.
Include the API client class.
Instantiate a new client. The required parameters are the application id and the application secret provided by Foursquare after registering your application.
Getting an access token from a user
Certain API requests require permission from the users in order to access their information. The following code demonstrates how to retrieve and store the token that grants permission to your application.
Performing requests
The API client exposes a method for each of the resources available in the Foursquare API, this resources are: users, venues, venue groups, checkins, tips, lists, updates, photos, settings, specials, events and page updates. Each one of them has its own methods and arguments so the resulting structure of an api request is:
Examples:
By reading the API documentation is easy to determine the methods that are available and the required arguments. The following code illustrates how to query the API, note that this time the access token is set directly.
Real time API
This functionality can be activated in the Foursquare application dashboard and allows your application to receive a POST request every time one of your users do a checkin. The wrapper allows you to validate the request and extract the information received.
Tests
To run the tests first you need to set an application id and an application secret in the file tests/FoursquareAPICredentials.php
then run the phpunit
command in the root folder of the project.