PHP Class FoursquareApi

Mostra file Open project: hownowstephen/php-foursquare Class Usage Examples

Public Properties

Property Type Description
$LastUrl last url sent
$ResponseHeaders String[]

Protected Properties

Property Type Description
$RedirectUri String

Public Methods

Method Description
AuthenticationLink ( String $redirect = '' ) AuthenticationLink Returns a link to the Foursquare web authentication page.
AuthorizeLink ( String $redirect = '' ) AuthorizeLink Returns a link to the Foursquare web authentication page. Using /authorize will ask the user to re-authenticate their identity and reauthorize your app while giving the user the option to login under a different account.
GeoLocate ( String $addr ) : array(lat, GeoLocate Leverages the google maps api to generate a lat/lng pair for a given address packaged with FoursquareApi to facilitate locality searches.
GetMulti ( Array $requests = false, boolean $POST = false ) GetMulti Performs a request for up to 5 private or public resources
GetPrivate ( String $endpoint, Array $params = false, boolean $POST = false ) GetPrivate Performs a request for a private resource
GetPublic ( String $endpoint, Array $params = false ) GetPublic Performs a request for a public resource
GetToken ( $code, $redirect = '' ) GetToken Performs a request to Foursquare for a user token, and returns the token, while also storing it locally for use in private requests
SetAccessToken ( String $token ) SetAccessToken Basic setter function, provides an authentication token to GetPrivate requests
__construct ( boolean | String $client_id = false, boolean | String $client_secret = false, string $redirect_uri = '', String $version = 'v2', string $language = 'en', string $api_version = DEFAULT_VERSION ) Constructor for the API Prepares the request URL and client api params
getResponseFromJsonString ( $json )
setRedirectUri ( $uri )

Private Methods

Method Description
GET ( $url, $params = false ) GET Abstraction of the GET request
MakeUrl ( String $url, Array $params ) MakeUrl Takes a base url and an array of parameters and sanitizes the data, then creates a complete url with each parameter as a GET parameter in the URL
POST ( $url, $params = false ) POST Abstraction of a POST request
ParseHeaders ( $ch, $header ) : integer Callback function to handle header strings as they are returned by cUrl in the $this->Request() function Parses header strings into key/value pairs and stores them in $ResponseHeaders array
Request ( String $url, Array $params = false, $type = HTTP_GET ) Request Performs a cUrl request with a url generated by MakeUrl. The useragent of the request is hardcoded as the Google Chrome Browser agent

Method Details

GeoLocate() public method

GeoLocate Leverages the google maps api to generate a lat/lng pair for a given address packaged with FoursquareApi to facilitate locality searches.
public GeoLocate ( String $addr ) : array(lat,
$addr String An address string accepted by the google maps api
return array(lat,

GetMulti() public method

GetMulti Performs a request for up to 5 private or public resources
public GetMulti ( Array $requests = false, boolean $POST = false )
$requests Array An array of arrays containing the endpoint and a set of parameters to be appended to the request, defaults to false (none)
$POST boolean whether or not to use a POST request, e.g. for large request bodies. It does not allow you to call endpoints that mutate data.

GetPrivate() public method

GetPrivate Performs a request for a private resource
public GetPrivate ( String $endpoint, Array $params = false, boolean $POST = false )
$endpoint String A particular endpoint of the Foursquare API
$params Array A set of parameters to be appended to the request, defaults to false (none)
$POST boolean whether or not to use a POST request

GetPublic() public method

GetPublic Performs a request for a public resource
public GetPublic ( String $endpoint, Array $params = false )
$endpoint String A particular endpoint of the Foursquare API
$params Array A set of parameters to be appended to the request, defaults to false (none)

GetToken() public method

GetToken Performs a request to Foursquare for a user token, and returns the token, while also storing it locally for use in private requests
public GetToken ( $code, $redirect = '' )
$code The 'code' parameter provided by the Foursquare webauth callback redirect
$redirect The configured redirect_uri for the provided client credentials

SetAccessToken() public method

SetAccessToken Basic setter function, provides an authentication token to GetPrivate requests
public SetAccessToken ( String $token )
$token String A Foursquare user auth_token

__construct() public method

Constructor for the API Prepares the request URL and client api params
public __construct ( boolean | String $client_id = false, boolean | String $client_secret = false, string $redirect_uri = '', String $version = 'v2', string $language = 'en', string $api_version = DEFAULT_VERSION )
$client_id boolean | String
$client_secret boolean | String
$redirect_uri string
$version String Defaults to v2, appends into the API url
$language string
$api_version string https://developer.foursquare.com/overview/versioning

getResponseFromJsonString() public method

public getResponseFromJsonString ( $json )

setRedirectUri() public method

public setRedirectUri ( $uri )

Property Details

$LastUrl public_oe property

last url sent
public $LastUrl

$RedirectUri protected_oe property

protected String $RedirectUri
return String

$ResponseHeaders public_oe property

public String[] $ResponseHeaders
return String[]