By Dhiraj | June 19, 2008

WORKING WITH REST

rest-client.php

<?
$rs=”http://localhost/rest/rest-server.php”;
$qs=”";
$parray=array(’amount’=>”15.00″);
foreach($parray as $par=>$value){
$qs=$qs.”$par=”.urlencode($value).”&”; }
$uri=”$rs?$qs” . “aid=01″;
echo $qs . “<br>” . $uri . “<br>”;
$cobj=curl_init($uri);
curl_setopt($cobj,CURLOPT_RETURNTRANSFER,1);
$xml=curl_exec($cobj);
curl_close($cobj);
echo htmlspecialchars($xml);
?>

rest-server.php

<?
$amount=$_GET[”amount”];
if ($_GET[’aid’]!=”010915780″)
{
echo “Invalid A ID”;

}
else
{
$taxcalc=$amount;
echo “<?xml version=\”1.0\”?>”;
echo “<taxinfo>”;
echo “<result>”.$taxcalc.”</result>”;
echo “<result>”.$taxcalc * 20 .”</result>”;
echo “</taxinfo>”;
}
?>

Test It.

Digg Facebook Technorati Bloglines

Email This Post Email This Post
Topics: Scripts |

Leave a Comment

Name:

E-Mail :

Website :

Comments :

Ad
Ad

Forum

Calendar

August 2008
M T W T F S S
« Jun «-»  
 123
45678910
11121314151617
18192021222324
25262728293031

Search

Polls

  • Who will rule the world?

    View Results

    Loading ... Loading ...