print_r($r->getBody()); echo '</pre>'; echo '<h1>Forms</h1>'; echo '<h2>GET</h2>'; echo '<p>Here is a GET form to see what kind of request it will create.</p>'; echo '<form name="input_get" action="/" method="get">'; echo 'First Name: <input type="text" name="first_name" /><br/>'; echo 'Last Name: <input type="text" name="last_name" /><br/>'; echo 'Are You Awesome? <input type="checkbox" name="is_awesome" /><br/>'; echo 'Your Credit Card Number: <input type="password" name="password" /><br/>'; echo '<input type="submit" value="Send!" name="submit_btn" />'; echo '</form>'; echo '<h2>POST</h2>'; echo '<p>Here is a POST form to see what kind of request it will create.</p>'; echo '<form name="input_post" action="/" method="post">'; echo 'First Name: <input type="text" name="first_name" /><br/>'; echo 'Last Name: <input type="text" name="last_name" /><br/>'; echo 'Are You Awesome? <input type="checkbox" name="is_awesome" /><br/>'; echo 'Your Credit Card Number: <input type="password" name="password" /><br/>'; echo '<input type="submit" value="Send!" name="submit_btn" />'; echo '</form>'; echo '</body></html>'; } $server = new StupidHttp_WebServer(); $server->onPattern('GET', '.*')->call(function ($c) { print_request($c->getRequest()); }); $server->onPattern('POST', '.*')->call(function ($c) { print_request($c->getRequest()); }); $server->run(array('run_browser' => true));
<?php $url = $_GET['url']; $auth = $_GET['auth']; //print_r($_POST); $json = print_request(); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: ' . $auth, 'Accept: application/json')); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); //$info = curl_getinfo($ch); //print $info['http_code']. "\n"; print $result; function print_request() { $body = ''; $fh = @fopen('php://input', 'r'); if ($fh) { while (!feof($fh)) { $s = fread($fh, 1024); if (is_string($s)) { $body .= $s; } } fclose($fh); } return $body;