.
This commit is contained in:
parent
cbcc2d9217
commit
438122dbc9
1 changed files with 42 additions and 17 deletions
|
@ -68,34 +68,59 @@
|
|||
if(isset($_POST["go"]))
|
||||
{
|
||||
|
||||
$url = 'localhost:5000/api/katalog';
|
||||
$form = array(
|
||||
"Title"=>$_POST["Title"],
|
||||
"Author"=>$_POST["Author"],
|
||||
"Country"=>$_POST["Country"],
|
||||
"Link"=>$_POST["Link"],
|
||||
"Language"=>$_POST["Language"],
|
||||
"Pages"=>$_POST["Pages"],
|
||||
"Year"=>$_POST["Year"],
|
||||
"LendTime"=>$_POST["LendTime"],
|
||||
"Category"=>$_POST["Category"],
|
||||
"ImageLink"=>$_POST["ImageLink"],
|
||||
"LendType"=>$_POST["LendType"]);
|
||||
"title"=>$_POST["Title"],
|
||||
"author"=>$_POST["Author"],
|
||||
"country"=>$_POST["Country"],
|
||||
"link"=>$_POST["Link"],
|
||||
"language"=>$_POST["Language"],
|
||||
"pages"=>$_POST["Pages"],
|
||||
"year"=>$_POST["Year"],
|
||||
"category"=>$_POST["Category"],
|
||||
"imageLink"=>$_POST["ImageLink"],
|
||||
"lendTime"=>$_POST["LendTime"],
|
||||
"lendType"=>$_POST["LendType"]);
|
||||
$json = json_encode($form);
|
||||
$data = $form;
|
||||
|
||||
$context = stream_context_create(array(
|
||||
'http' => array(
|
||||
'method' => 'POST',
|
||||
'header' => "Content-type: application/json\r\n",
|
||||
'content' => $json
|
||||
)
|
||||
));
|
||||
|
||||
// Send the request
|
||||
|
||||
$response= file_get_contents('http://localhost:5000/api/katalog/buch', false, $context);
|
||||
echo $response;
|
||||
// Check for errors
|
||||
if($response === FALSE){
|
||||
die('Error');
|
||||
}
|
||||
|
||||
// Decode the response
|
||||
$responseData = json_decode($response, TRUE);
|
||||
|
||||
// Print the date from the response
|
||||
echo $responseData['productId'];
|
||||
|
||||
//$data = $form;
|
||||
/*
|
||||
// use key 'http' even if you send the request to https://...
|
||||
$options = array(
|
||||
'http' => array(
|
||||
'header' => "Content-type: application/json\r\n",
|
||||
'method' => 'POST',
|
||||
'content' => http_build_query($data),
|
||||
'content' => http_build_query($form),
|
||||
),
|
||||
);
|
||||
$context = stream_context_create($options);
|
||||
//echo $context;
|
||||
$result = file_get_contents('http://localhost:5000/api/katalog/');
|
||||
echo $result;
|
||||
// $result = file_get_contents('http://localhost:5000/api/katalog/');
|
||||
//$bloed= file_put_contents('http://localhost:5000/api/katalog/', $form, FILE_APPEND);
|
||||
*/
|
||||
// http://www.php.net/manual/en/context.http.php
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue