dev-master
9999999-devSimple CakePHP API endpoints plugin for simplicity in connecting to API endpoints
The Requires
by bmilesp
Simple CakePHP API endpoints plugin for simplicity in connecting to API endpoints
Simple CakePHP API endpoints plugin for simplicity in connecting to API endpoints, (*1)
CakePHP => 2.1, (*2)
[Using Composer], (*3)
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:, (*4)
{ "require": { "bmilesp/endpoints": "2.1.x-dev" } }
Add following lines in yout app/Config/bootstrap.php file, (*5)
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');
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; }
Simple CakePHP API endpoints plugin for simplicity in connecting to API endpoints