php curl调用如java开发的restful接口
curl调用如java开发的restful接口 这是公司平台用到的curl调用接口。框架是使用Kohana,因此里面有几处地方需要使用者更加自己的实际情况做修改。压缩包解压后 com/api/connector.php 107行、
这是公司平台用到的curl调用接口。框架是使用Kohana,因此里面有几处地方需要使用者更加自己的实际情况做修改。
压缩包解压后 com/api/connector.php 107行、123行以及152行。修改的是读取配置的地方和url拼装后的后缀。
<?php
/*
* 调用例子
*/
define( 'SYSPATH', './base/http/' );
define( 'APIPATH', './com/api/' );
require_once SYSPATH.'client.php';
require_once SYSPATH.'response.php';
require_once SYSPATH.'client/curl.php';
require_once APIPATH.'connector.php';
require_once APIPATH.'response.php';
require_once APIPATH.'app/query.php';
$result = Com_Api_App_Query::get( array( 'test' => 'Hello world' ) );
if ( FALSE === $result )
{
echo Com_Api_Response::getError();exit;
}
var_dump( $result );
echo '<br><br>';
$result = Com_Api_App_Query::get( array( 'test' => 'Hello world' ) );
if ( FALSE === $result )
{
echo Com_Api_Response::getError();exit;
}
var_dump( $result );
//该片段来自于http://outofmemory.cn
精彩图集
精彩文章






