From 395d3f5e57d2c39cb3bd1a7ee8e768507b5d1e6b Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Sun, 9 Aug 2015 12:38:58 +0200 Subject: adding POST to give the backend the needed JSON for generating the contract. I.e. adding POST /contract --- src/frontend/cert.php | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'src/frontend/cert.php') diff --git a/src/frontend/cert.php b/src/frontend/cert.php index a330d76e..9f0af350 100644 --- a/src/frontend/cert.php +++ b/src/frontend/cert.php @@ -60,27 +60,30 @@ else{ 'currency' => $currency))); // test // echo $json; - // send to backend - /* // _very_ problematic - $http_obj = new HttpRequest; - $http_obj.setMethod (METH_GET); - //$http_obj.setBody ($json); - $http_obj.send (); - $http_obj.setUrl ("http://" . $SERVER["SERVER_NAME"] . "/backend" . "/hello"); - $status = $http_obj.getResponseHeader ('status'); - */ - $client = new http\Client; - $certificate = http_post_data ("http://" . $SERVER["SERVER_NAME"] . "/backend" . "/hello", - null, $response); - $status_code = $response['response_code']; - - set_response_code ($status_code); + + //echo phpinfo (); + + // crafting the request + $req = new http\Client\Request ("POST", + "http://" . $SERVER["SERVER_NAME"] . "/backend" . "/contract", + //"http://localhost:9898/", + array ("Content-Type" => "application/json")); + $req->getBody()->append ($json); - if ($status != 200) - echo "Some error occurred during this operation"; + $client = new http\Client; + $client->enqueue($req)->send (); + $resp = $client->getResponse (); + $status_code = $resp->getResponseCode (); + http_response_code ($status_code); + + + if ($status_code != 200){ + echo "Error while generating the certificate, response code : " . $status_code; + } // send the contract back to the wallet without touching it - else echo $http_obj.getResponseBody (); - + else{ + echo $resp->body->toString (); + } } -- cgit v1.2.3