note 104767 deleted from function.explode by danbrown

From: Date: Wed, 06 Jul 2011 13:26:26 +0000
Subject: note 104767 deleted from function.explode by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-181283@lists.php.net to get a copy of this message
Note Submitter: jeffmixpute ---- <?php // a simple client (explode will used in service) $url = "http://localhost/~student/Sites/rest-service.php"; $chget = curl_init(); $chpost = curl_init(); $chput = curl_init(); $chdelete = curl_init(); curl_setopt($chget, CURLOPT_URL, $url . "/ressource63"); curl_setopt($chget, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($chget); echo $response; $data = <<<XML <xml><name>chris</name></xml> XML; curl_setopt($chpost, CURLOPT_URL, $url); curl_setopt($chpost, CURLOPT_POST, true); curl_setopt($chpost, CURLOPT_RETURNTRANSFER, true); curl_setopt($chpost, CURLOPT_POSTFIELDS, $data); $response = curl_exec($chpost); echo $response; curl_setopt($chput, CURLOPT_URL, $url); curl_setopt($chput, CURLOPT_PUT, true); curl_setopt($chput, CURLOPT_RETURNTRANSFER, true); curl_setopt($chput, CURLOPT_INFILE, fopen("./file.txt", "r")); curl_setopt($chput, CURLOPT_INFILESIZE, 100); // size of the file in bytes $response = curl_exec($chput); echo $response; curl_setopt($chdelete, CURLOPT_URL, $url . "/ressource56"); curl_setopt($chdelete, CURLOPT_CUSTOMREQUEST, "DELETE"); curl_setopt($chdelete, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($chdelete); echo $response; curl_close($chget); curl_close($chpost); curl_close($chput); curl_close($chdelete); ?> <?php // ... and a simple service to make some tests $path = $_SERVER["PATH_INFO"]; $daten = explode("/", $path); // explode in action! if($_SERVER["REQUEST_METHOD"] == "GET") { echo "get: " . $daten[1] . "<br/>\n"; return; } elseif($_SERVER["REQUEST_METHOD"] == "POST") { $xml = simplexml_load_string(file_get_contents("php://input")); echo "post: " . $xml->name . "<br/>\n"; return; } elseif($_SERVER["REQUEST_METHOD"] == "PUT") { echo "put: " . file_get_contents("php://input") . "<br/>\n"; return; } elseif($_SERVER["REQUEST_METHOD"] == "DELETE") { echo "del: " . $daten[1] . "<br/>\n"; return; } ?>

« previous php.notes (#181283) next »