Skip to content
This repository has been archived by the owner on May 8, 2021. It is now read-only.

A datasource that makes the Foursquare API methods available in CakePHP

License

Notifications You must be signed in to change notification settings

tijs/cakephp-foursquare-datasource

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

CakePHP Foursquare Datasource

Note: This datasource is not yet compatible with the v2 API, feel free to update it if you need this functionality!

This datasource acts as a basic wrapper for the Foursquare API that allows you to interact with the API from Cake as you would with any model.

Installation

  1. Place foursquare_source.php in your app/models/datasources folder
  2. Add the credentials to database.php
  3. Add your datasource and call some methods

Step 1: Place foursquare_source.php in your app/models/datasources folder

Simply check out or download this repository to your app folder and make sure everything is in the right place.

Step 2: Add the credentials to database.php

Your database configuration would look something like this:

<?php
class DATABASE_CONFIG {

    /* these would be your existing DB credentials */
	var $default = array(
	    //...
	);

    /* and here we have your Foursquare credentials */
    var $foursquare = array( 
        'datasource' => 'foursquare', 
        'email' => 'your_foursquare_email_adress', 
        'password' => 'your_foursquare_password', 
    );
    
}
?>

Step 3: Add your datasource and call some methods

An example where you make your Foursquare data available right into a controller would look something like this:

<?php 
class FoursquareController extends AppController {

    /* we don't want annoying warnings about missing tables */
    var $uses = array(); 

    function index(){ 

        /* We initialize the new datasource like so */
        $this->Foursquare = ConnectionManager::getDataSource('foursquare');
        
        /* And then we call any of the available methods, the venues method in this case */
        $result = $this->Foursquare->venues('51.914835', '4.473985', null, 10); // params: lat, long, name, limit

        debug($result); // returns an array with 10 venues near the Boijmans van Beuningen Museum in Rotterdam, the Netherlands

    } 
} 
?>

About

A datasource that makes the Foursquare API methods available in CakePHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages