bmilesp / endpoints
该包的最新版本(dev-master)没有可用的许可信息。
简单的 CakePHP API 端点插件,简化 API 端点连接
dev-master
2015-02-27 15:17 UTC
Requires
- composer/installers: ~1.0
This package is not auto-updated.
Last update: 2024-09-24 02:47:05 UTC
README
简单的 CakePHP API 端点插件,简化 API 端点连接
要求
CakePHP => 2.1
安装
[使用 Composer]
在 Packagist 上查看,并将最新版本的 json 片段复制到您的项目的 composer.json
文件中。例如,v. 2.1.x-dev 将看起来像这样
{ "require": { "bmilesp/endpoints": "2.1.x-dev" } }
启用插件
在您的 app/Config/bootstrap.php 文件中添加以下行
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; }