您的位置:首页 > 编程语言 > PHP开发

php之web页面之间的接口调用

2009-02-10 15:10 603 查看
//调用页面testgetjson.php

<html>
<head>
<!--set title-->
<title> post json data  </title>
</head>
<!--show page-->
<body>
<?php
require_once("../json/json.php");

$strJson = file_get_contents('http://localhost/lian/testpostjson.php', 1000000);
echo "get json string:<br>/n";
echo "$strJson <br>/n";
$objJson = new Services_JSON();
$obj = $objJson->decode($strJson);

echo "the orgin data: <br>/n";
var_dump($objJson);
var_dump($obj);
echo "<br>/n";
?>
</body>
</html>


//被调用页面 testpostjson.php

<?php
require_once("../json/json.php");
$arr = array('name' => 'andylin', 'nick' => 'congfeng', 'contact' => array('email' =>'andylin02@126.com', 'website' => 'http://blog.csdn.net/andylin02'));

$objJson = new Services_JSON();
$strJson = $objJson->encode($arr);
echo "$strJson";
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: