Home > php教程 > PHP源码 > body text

curl调用如java开发的restful接口

PHP中文网
Release: 2016-05-25 17:10:56
Original
1443 people have browsed it

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 );
Copy after login
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!