Simultan Test
| From: | Peter Griffin | Date: | Wed, 25 Jan 2012 16:41:26 +0000 |
| Subject: | Simultan Test | ||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-66057@lists.php.net to get a copy of this message | ||
//-- RESTful Client -- //
<?php
// Server-URL
$url = "http://localhost/restfulserver.php";
// curl init
$ch = curl_init();
// Var
$method = "GET";
$data = "Test";
$xml = "<xml><text>Die ist ein Test</text></xml>";
if ($method == "GET")
{
curl_setopt($ch, CURLOPT_URL, $url."/".$data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
curl_exec($ch);
}
elseif ($method == "POST")
{
curl_setopt($ch, CURLOPT_URL, $url."/".$data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_exec($ch);
}
elseif ($method == "DELETE")
{
curl_setopt($ch, CURLOPT_URL, $url."/".$data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_exec($ch);
}
curl_close($ch);
?>
//-- RESTful Server -- //
<?php
// Include
include "sequence.php";
$url = $_SERVER['PATH_INFO'];
$seq = new Sequence();
if(!isset($_SERVER['PATH_INFO']))
{
echo "Fehler";
return;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$url = explode("/",$url);
$xml = file_get_contents("php://input");
$seq->setzeSequence($url[1],$xml);
}
elseif ($_SERVER['REQUEST_METHOD'] == 'GET')
{
header('Content-Type: text/xml');
$url = explode("/", $url);
$response = $seq->holeSequence($url[1]);
foreach($response as $value)
{
echo $value;
}
}
elseif ($_SERVER['REQUEST_METHOD'] == 'DELETE')
{
$url = explode("/", $url);
$seq->loescheSequence($url[1]);
}
else
{
echo header("HTTP/1.1 501 Not Implemented");
}
?>
--
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de