2020-06-10 08:22:49 +00:00
|
|
|
<?php /*
|
2020-06-09 10:40:49 +00:00
|
|
|
if(isset($_POST["go"]))
|
|
|
|
{
|
|
|
|
$form = array(
|
|
|
|
"Title"=>$_POST["Title"],
|
|
|
|
"Author"=>$_POST["Author"]);
|
|
|
|
$json = json_encode($form);
|
2020-06-09 11:32:38 +00:00
|
|
|
//echo $json;
|
2020-06-10 08:22:49 +00:00
|
|
|
|
2020-06-09 10:40:49 +00:00
|
|
|
// Dieser Schritt dient nur um die Daten wieder in der Ausgabe anzeigen zu lassen,
|
2020-06-10 08:35:44 +00:00
|
|
|
//muss später noch an eine andere Stelle gepackt werden (z.B. nach dem Empfang von Daten aus der API)
|
2020-06-09 12:24:56 +00:00
|
|
|
$json2= json_decode($json, true);
|
2020-06-10 08:22:49 +00:00
|
|
|
} */
|
|
|
|
?>
|
|
|
|
|
|
|
|
<?php
|
2020-06-11 09:48:57 +00:00
|
|
|
/*fsockopen('www.google.com', 80);
|
2020-06-10 12:32:20 +00:00
|
|
|
|
2020-06-10 08:22:49 +00:00
|
|
|
//Zugriff auf API
|
|
|
|
if(isset($_POST["go"]))
|
|
|
|
{
|
|
|
|
$Title= $_POST['Title'];
|
2020-06-10 12:32:20 +00:00
|
|
|
$url= "https://localhost:5001/api/katalog"; // stimmt die URL?
|
2020-06-10 08:22:49 +00:00
|
|
|
$client = curl_init($url);
|
2020-06-10 12:32:20 +00:00
|
|
|
$result= file_get_contents($url);
|
|
|
|
//$fp = @fsockopen($client, 80, $errno, $errstr);
|
|
|
|
$response=curl_exec($url);
|
2020-06-10 08:22:49 +00:00
|
|
|
echo $errstr;
|
|
|
|
//echo $fp;
|
2020-06-10 12:32:20 +00:00
|
|
|
echo $response;
|
|
|
|
|
2020-06-10 08:22:49 +00:00
|
|
|
|
2020-06-10 08:35:44 +00:00
|
|
|
|
2020-06-10 08:22:49 +00:00
|
|
|
$result = json_decode($response);
|
2020-06-10 12:32:20 +00:00
|
|
|
echo $result;
|
2020-06-10 08:22:49 +00:00
|
|
|
$form = array(
|
|
|
|
"Title"=>$_POST["Title"],
|
|
|
|
"Author"=>$_POST["Author"]);
|
|
|
|
$json = json_encode($form);
|
|
|
|
|
|
|
|
|
|
|
|
// Dieser Schritt dient nur um die Daten wieder in der Ausgabe anzeigen zu lassen,
|
|
|
|
//muss später noch an eine andere Stelle gepackt werden 8z.B. nach dem Empfang von Daten aus der API)
|
|
|
|
$json2= json_decode($json, true);
|
2020-06-11 09:48:57 +00:00
|
|
|
}*/
|
2020-06-10 08:22:49 +00:00
|
|
|
?>
|
|
|
|
|
|
|
|
<?php /*
|
|
|
|
//nur zum Test einer GET-Methode
|
|
|
|
if(isset($_GET["test"]))
|
|
|
|
{
|
|
|
|
$url= "http://localhost:5000/api/katalog/1";
|
|
|
|
$contents = file_get_contents($url);
|
|
|
|
if($contents !== false){
|
|
|
|
//Print out the contents.
|
|
|
|
echo $contents;
|
|
|
|
}
|
|
|
|
|
|
|
|
//$client = curl_init($url);
|
|
|
|
//$response=curl_exec($client);
|
|
|
|
$Title= $_GET['Title'];
|
|
|
|
$result = json_decode($response);
|
|
|
|
echo $result['title'];
|
|
|
|
}*/
|
2020-06-09 10:40:49 +00:00
|
|
|
?>
|
|
|
|
|
2020-06-11 09:48:57 +00:00
|
|
|
<?php
|
|
|
|
if(isset($_POST["go"]))
|
|
|
|
{
|
|
|
|
|
|
|
|
$form = array(
|
2020-06-11 11:27:04 +00:00
|
|
|
"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"]);
|
2020-06-11 09:48:57 +00:00
|
|
|
$json = json_encode($form);
|
2020-06-11 11:27:04 +00:00
|
|
|
|
|
|
|
$context = stream_context_create(array(
|
|
|
|
'http' => array(
|
|
|
|
'method' => 'POST',
|
|
|
|
'header' => "Content-type: application/json\r\n",
|
|
|
|
'content' => $json
|
|
|
|
)
|
|
|
|
));
|
2020-06-11 09:48:57 +00:00
|
|
|
|
2020-06-11 11:27:04 +00:00
|
|
|
// 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;
|
|
|
|
/*
|
2020-06-11 09:48:57 +00:00
|
|
|
// use key 'http' even if you send the request to https://...
|
|
|
|
$options = array(
|
|
|
|
'http' => array(
|
|
|
|
'header' => "Content-type: application/json\r\n",
|
|
|
|
'method' => 'POST',
|
2020-06-11 11:27:04 +00:00
|
|
|
'content' => http_build_query($form),
|
2020-06-11 09:48:57 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
$context = stream_context_create($options);
|
|
|
|
//echo $context;
|
2020-06-11 11:27:04 +00:00
|
|
|
// $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
|
2020-06-11 09:48:57 +00:00
|
|
|
}
|
|
|
|
|
2020-06-11 11:27:04 +00:00
|
|
|
?>
|
2020-06-11 09:48:57 +00:00
|
|
|
|
2020-06-09 09:32:44 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="de">
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>Katalog</title>
|
|
|
|
<link rel="stylesheet" type="text/css" href="scss/style.css" media="screen" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="Titel">
|
|
|
|
<a href="index.html"><button id= "zurueck">zurück</button></a>
|
|
|
|
<h1>Katalog</h1>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="Eingabe">
|
|
|
|
<h2>Eingabe</h2>
|
2020-06-10 08:22:49 +00:00
|
|
|
<form method="post">
|
2020-06-09 09:32:44 +00:00
|
|
|
<input type="text" name="Title" class="input" placeholder="Titel">
|
|
|
|
<input type="text" name="Author" class="input" placeholder="Autor">
|
|
|
|
<input type="text" name="Country" class="input" placeholder="Herkunft">
|
|
|
|
<input type="url" name="Link" class="input" placeholder="Link">
|
|
|
|
<input type="text" name="Language" class="input" placeholder="Sprache">
|
|
|
|
<input type="number" name="Pages" class="input" placeholder="Seiten" min="0">
|
|
|
|
<input type="number" name="Year" class="input" placeholder="Erscheinungsjahr" min="0">
|
|
|
|
<select class="input" name="Category">
|
|
|
|
<option>Book</option>
|
|
|
|
<option>Magazin</option>
|
|
|
|
<option>EBook</option>
|
|
|
|
<option>EPaper</option>
|
|
|
|
</select>
|
|
|
|
<input type="url" name="ImageLink" class="input" placeholder="Bild">
|
|
|
|
<input type="number" name="LendTime" class="input" placeholder="Verteihdauer" min="0">
|
2020-06-11 09:48:57 +00:00
|
|
|
<select class="input" name="LendType">
|
2020-06-09 09:32:44 +00:00
|
|
|
<option>Physical</option>
|
|
|
|
<option>Virtual</option>
|
|
|
|
</select>
|
|
|
|
<input type="submit" name="go" id="go">
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<div class="Ausgabe">
|
|
|
|
<h2>Ausgabe</h2>
|
|
|
|
<table>
|
|
|
|
<tr>
|
|
|
|
<td class ="fix">ProductId</td>
|
|
|
|
<td> </td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
2020-06-09 10:40:49 +00:00
|
|
|
<td class="fix">Titel</td>
|
2020-06-10 08:22:49 +00:00
|
|
|
<td><?php if(isset($_POST["go"])) echo $json2['Title']; ?></td>
|
2020-06-09 09:32:44 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="fix">Autor</td>
|
2020-06-10 08:22:49 +00:00
|
|
|
<td><?php if(isset($_POST["go"])) echo $json2['Author']; ?></td>
|
2020-06-09 09:32:44 +00:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="fix">Land</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="fix">Link</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="fix">Sprache</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="fix">Seitenzahl</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="fix">Erscheinungsjahr</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="fix">Kategorie</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="fix">Bildlink</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="fix">Verleihdauer</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="fix">Verleihtyp</td>
|
|
|
|
<td></td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|