bmilesp/endpoints

There is no license information available for the latest version (dev-master) of this package.

Simple CakePHP API endpoints plugin for simplicity in connecting to API endpoints

Installs: 38

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 0

Open Issues: 0

Type:cakephp-plugin

dev-master 2015-02-27 15:17 UTC

This package is not auto-updated.

Last update: 2024-12-17 03:51:10 UTC


README

Simple CakePHP API endpoints plugin for simplicity in connecting to API endpoints

Requirements

CakePHP => 2.1

Installation

[Using Composer]

View on Packagist, and copy the json snippet for the latest version into your project's composer.json. Eg, v. 2.1.x-dev would look like this:

{
	"require": {
		"bmilesp/endpoints": "2.1.x-dev"
	}
}

Enable plugin

Add following lines in yout app/Config/bootstrap.php file

Create a database config variable that uses the Endpoints.ApiSource datasource, and the API domain as the host:
	
	public $website_source = array(
    	'datasource' => 'Endpoints.ApiSource',
    	'host' => 'website.com'
    );
Then setup the model by using the behavior and datasource we've just setup:
	
	public $uses = array('website_source');
	public $actsAs = array('Endpoints.Endpint');

Usage

To send and retrieve data from an endpoint. here is an example:
	function unlock($slug = null){
		$postData = array('id' => 23);
		$result = $this->callEndpoint('/users/get_user_by_id',$postData);
		return $result->body; 	
	}