Home  >  Article  >  php教程  >  curl调用如java开发的restful接口

curl调用如java开发的restful接口

PHP中文网
PHP中文网Original
2016-05-25 17:10:561433browse

php代码

<?php
/*
 * 调用例子
 */

define( &#39;SYSPATH&#39;, &#39;./base/http/&#39; );
define( &#39;APIPATH&#39;, &#39;./com/api/&#39; );

require_once SYSPATH.&#39;client.php&#39;;
require_once SYSPATH.&#39;response.php&#39;;
require_once SYSPATH.&#39;client/curl.php&#39;;

require_once APIPATH.&#39;connector.php&#39;;
require_once APIPATH.&#39;response.php&#39;;
require_once APIPATH.&#39;app/query.php&#39;;

$result = Com_Api_App_Query::get( array( &#39;test&#39; => &#39;Hello world&#39; ) );

if ( FALSE === $result )
{
    echo Com_Api_Response::getError();exit;
}

var_dump( $result );

echo &#39;<br><br>&#39;;

$result = Com_Api_App_Query::get( array( &#39;test&#39; => &#39;Hello world&#39; ) );

if ( FALSE === $result )
{
    echo Com_Api_Response::getError();exit;
}

var_dump( $result );
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php简单的数组递归Next article:免费人脸识别api